ios - 如何防止人们选择器导航 Controller 自动解雇

标签 ios ipad ios8 peoplepicker

在 iOS 8 中,以下内容已弃用:

-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person

现在我们应该使用:

-(void)peoplePickerNavigationController:didSelectPerson:

但此方法会在第一次选择后自动关闭人员选择器,而旧版本不会。我有一个例程,需要将用户选择的每个名称一一记录下来。我可以在每次选择后重新显示人员选择器,但它会从名字开始重新启动联系人列表。

希望我解释正确。有人知道如何防止 peoplepickernavigationcontroller 在 iOS 8 中像在 ios7 中那样自动关闭吗?

最佳答案

在 ABPeoplePickerNavigationController 的文档中,查看 predicateForSelectionOfPerson 的注释。

// Optionally determines if a selected person should be returned to the app (predicate evaluates to TRUE),
// or if the selected person should be displayed (predicate evaluates to FALSE).
// If not set and -peoplePickerNavigationController:didSelectPerson: is implemented the selected person is returned to the app,
// or if not set and -peoplePickerNavigationController:didSelectPerson:identifier: is implemented the selected person is displayed.
//
@property(nonatomic,copy) NSPredicate *predicateForSelectionOfPerson NS_AVAILABLE_IOS(8_0);

所以你需要设置一个谓词为FALSE,如果你想显示选中的人。

    if ([picker respondsToSelector:@selector(setPredicateForSelectionOfPerson:)])
{
    picker.predicateForSelectionOfPerson = [NSPredicate predicateWithValue:NO];
}

关于ios - 如何防止人们选择器导航 Controller 自动解雇,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25954937/

相关文章:

ios - Swift PHImageManager 照片库图像在选择 Collection View 单元格后获取 PHImageManagerMaximumSize

ios - iPad性能问题

swift - 使用Swift录制和播放视频并将视频发送到服务器

ios - 带导航栏的 UIWebView

ios - 如何获取 imessage 扩展程序创建的应用程序的电话号码

ios - 社交媒体和我自己在应用程序中登录/注册

ios - 如何将图像添加到 ios 中 uicollectionView 单元格的左上角?

ios - 在 IOS 上使用 CollectionView 的弹出窗口

ios - 如何判断哪个应用程序正在运行我的 iOS 8 扩展

ios - 在 iOS8 上使用 UIImagePicker 结果 URL 和 PHAsset 从 "My Photo Stream"加载图像