0

在 Apple 日历应用程序中,如果您邀请人们参加活动,您将在标题下看到特定文本:

苹果日历

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

我的应用

按钮的 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;
}
4

1 回答 1

1

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

更新

不幸的是,它似乎ABPeoplePickerNavigationController不能直接添加到情节提要中;请参阅此答案以查看解决方法。

于 2014-06-15T21:19:34.527 回答