【问题标题】:Custom text over ABPeoplePickerNavigationController "All Contacts" headerABPeoplePickerNavigationController“所有联系人”标题上的自定义文本
【发布时间】:2014-06-16 05:46:25
【问题描述】:

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

在我的应用中,我也在使用人员选择器。我想在 All Contacts 标题上为用户添加自定义提示。

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

【问题讨论】:

    标签: ios abaddressbook abpeoplepickerview


    【解决方案1】:

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

    更新

    不幸的是,ABPeoplePickerNavigationController 似乎无法直接添加到情节提要中;请参考this answer 了解解决方法。

    【讨论】:

      猜你喜欢
      • 2021-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-24
      • 1970-01-01
      • 1970-01-01
      • 2021-04-27
      • 1970-01-01
      相关资源
      最近更新 更多