开发者

ABAddressBook filtered contacts

I want to show the filtered list of contacts in ABPeoplePickerNavigationController, the persons who have their email address should be shown, and those who dont have email address should not be in the开发者_StackOverflow中文版 list, anybody knows how to do it?

Thanks in advance.


Hi you can use the peoplePickerNavigationController Delegate to do this

-(BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
 {
    if(!ABRecordCopyValue(person,kABPersonEmailProperty) //Check if email field is empty
    { 
         [peoplePicker dismissModalViewControllerAnimated:NO]; //dismiss the person with email field empty
    } 
    return YES;
    }
}

Dont forget to add delegate on your interface with tags in the .h file

ie,

#import <UIKit/UIKit.h>
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>

@interface ViewController : UITableViewController<ABNewPersonViewControllerDelegate,ABPeoplePickerNavigationControllerDelegate,ABPersonViewControllerDelegate,UIAlertViewDelegate>


You can use below link the same way with Email addresses. Can't set the addressBook property of ABPeoplePickerNavigationController without crashing

The only problem is with the ABAddressBookRemoveRecord which is causing failures.

If I were you I would iterate through all contacts, get the names of the contacts with an email address and get there email addresses. Then put them in a TableView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜