Jac*_*ano 6 peoplepicker ipad ios ios8
在iOS 8中,不推荐使用以下内容:
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
现在我们应该使用:
- (无效)peoplePickerNavigationController:didSelectPerson:
但是这个方法会在第一次选择之后自动解除人员选择器,旧版本没有.我有一个例程,需要记录用户逐个选择的每个名称.我可以在每次选择后重新显示人员选择器,但它会以第一个名称重新开始联系人列表.
我希望我能正确解释这一点.任何人都知道如何在iOS 8中保持peoplepickernavigationcontroller不像过去那样在ios7中自动解散?
我找到了在选择属性后重新显示人员选择器的解决方案。
实现处理一个人选择联系人属性时的委托方法(仅由 iOS 8 调用):对我来说,技巧是关闭选择器,然后立即在完成委托中调用我的“显示选择器”方法(是的,其中的委托)代表)。
// Dismisses the people picker and shows the application when users tap Cancel.
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
[self.picker dismissViewControllerAnimated:NO completion:^{
NSLog(@"just dismissed the picker");
[self showPeoplePickerController];
}];
}
Run Code Online (Sandbox Code Playgroud)
如果您希望人员选择器显示在上次停止的位置,请务必初始化一次。希望这可以帮助
这是我的 showPeoplePickerController 方法
#pragma mark Show all contacts
// Called when users tap "Display Picker" in the application. Displays a list of contacts and allows users to select a contact from that list.
-(void)showPeoplePickerController
{
picker.peoplePickerDelegate = self;
picker.delegate = self;
picker.visibleViewController.searchDisplayController.searchBar.delegate = self;
[self presentViewController:picker animated:NO completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
首先初始化选择器。请注意,联系人访问首先需要调用授权方法
picker = [[ABPeoplePickerNavigationController alloc] init];
//have self prompt first, then based off answer prompt them with internal address book stuff or now
if(ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized)
{
// show picker UI if the user has granted access to their Contacts
[self showPeoplePickerController];
}
Run Code Online (Sandbox Code Playgroud)
笔记:
归档时间: |
|
查看次数: |
2021 次 |
最近记录: |