ABPeoplePickerNavigationController上的自定义文本"所有联系人"头

时间:2014-06-15 20:56:44

标签: ios abaddressbook abpeoplepickerview

在Apple日历应用中,如果您邀请人参加活动,您会在标题下看到特定文字:

Apple Calendar

在我的应用中,我也在使用人物选择器。我想通过所有联系人标题为用户添加自定义提示。

My app

按钮的IBAction:

- (IBAction)showPicker:(UIBarButtonItem *)sender {
self.addressBookController = [[ABPeoplePickerNavigationController alloc] init];
[self.addressBookController setPeoplePickerDelegate:self];
self.addressBookController.displayedProperties = [NSArray arrayWithObjects:
                                                  [NSNumber numberWithInt:kABPersonPhoneProperty],
                                                  nil];
[self presentViewController:self.addressBookController animated:YES completion:nil];

}

所有委托方法:

#pragma mark Address Book Delegate

-(void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{
[self.addressBookController dismissViewControllerAnimated:YES completion:nil];
}


-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
return YES;
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {

ABMultiValueRef phonesRef = ABRecordCopyValue(person, property);
CFStringRef currentPhoneValue = ABMultiValueCopyValueAtIndex(phonesRef, identifier);

// Some custom code working with a phone number

return NO;
}

1 个答案:

答案 0 :(得分:1)

我认为无论如何都无法自定义ABPeoplePickerNavigationController。 您可以使用UIViewController(带有用户提示)和容器视图创建UILabel;然后将ABPeoplePickerNavigationController嵌入到容器视图中。这可以通过Interface Builder轻松实现,也可以通过编程方式完成,请参阅UIViewController的类参考概述中的Implementing a Container View Controller部分。

更新

不幸的是,ABPeoplePickerNavigationController似乎无法直接添加到Storyboard中;请参阅this answer以查看解决方法。