ABPersonViewController中常用属性方法解析如下:
//代理
@property(nonatomic,assign,nullable) id<ABPersonViewControllerDelegate> personViewDelegate;
//通讯录实例
@property(nonatomic,readwrite,nullable) ABAddressBookRef addressBook;
//联系人记录实例
@property(nonatomic,readwrite) ABRecordRef displayedPerson;
//展示的属性字段
@property(nonatomic,copy,nullable) NSArray<NSNumber*> *displayedProperties;
//是否允许编辑
@property(nonatomic) BOOL allowsEditing;
//是否允许活动按钮 例如分享
@property(nonatomic) BOOL allowsActions;
//是否允许关联其他联系人
@property(nonatomic) BOOL shouldShowLinkedPeople;
//设置属性高亮
- (void)setHighlightedItemForProperty:(ABPropertyID)property withIdentifier:(ABMultiValueIdentifier)identifier;
ABPersonViewControllerDelegate中方法解释如下:
//选择属性发送时调用
- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier;
五、关于ABUnknownPersonViewController
ABUnknownPersonViewController界面与ABPersonViewController基本一致,不同的是,ABPersonViewController需要使用一个通讯录中已经存在的联系人作为参数进行展示,ABUnknownPersonViewController则不然,你可以使用一个通讯录中不存在的联系人对象来进行界面的渲染,并且支持用户选择将此联系人存入通讯录中。示例如下:
ABUnknownPersonViewController *unknown=[[ABUnknownPersonViewController alloc]init];
unknown.displayedPerson=ABPersonCreate();
unknown.allowsAddingToAddressBook=YES;//允许添加
[self presentViewController:unknown animated:YES completion:nil];
ABUnknownPersonViewController中属性方法解释如下:
//代理
@property(nonatomic,assign,nullable) id<ABUnknownPersonViewControllerDelegate> unknownPersonViewDelegate;
//通讯录实例对象
@property(nonatomic,readwrite,nullable) ABAddressBookRef addressBook;
//联系人实例
@property(nonatomic,readwrite) ABRecordRef displayedPerson;
//提示名字
@property(nonatomic,copy,nullable) NSString *alternateName;
//提示信息
@property(nonatomic,copy,nullable) NSString *message;
//是否允许活动
@property(nonatomic) BOOL allowsActions;
//是否允许添加电话本
@property(nonatomic) BOOL allowsAddingToAddressBook;
ABUnknownPersonViewControllerDelegate方法:
//联系人解释时调用
- (void)unknownPersonViewController:(ABUnknownPersonViewController *)unknownCardViewController didResolveToPerson:(nullable ABRecordRef)person;
//发送活动
- (BOOL)unknownPersonViewController:(ABUnknownPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier;