遇到一个通讯录跳转的问题,对于联系人来说,如果只有一个电话号码就直接dismiss返回,否则进入详情页进行选择后返回。在iOS 9.0系统前后可做如下处理:
if([[UIDevice
currentDevice] systemVersion].floatValue >=
9.0){
CNContactPickerViewController *contactController = [CNContactPickerViewController
new];
contactController.delegate
= self;
[contactController
setPredicateForSelectionOfContact:[NSPredicate
predicateWithFormat:@"phoneNumbers.@count
== 1"]];
[controller
presentViewController:contactController
animated:YES
completion:nil];
}else{
ABPeoplePickerNavigationController *peoplePickerNavigationController = [ABPeoplePickerNavigationController
new];
peoplePickerNavigationController.peoplePickerDelegate
= self;
peoplePickerNavigationController.predicateForSelectionOfPerson
= [NSPredicate
predicateWithFormat:@"phoneNumbers.@count
== 1"];
[controller
presentViewController:peoplePickerNavigationController
animated:YES
completion:nil];
}
然后实现各自的两个点击联系人的协议,就OK啦!