说明:如果我设置“[[UIScrollView 外观] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];” 在我的应用程序的其他地方,CNContactPicerViewController 中的前两项将被覆盖并且无法触摸。在当前 Contact Picer 之前设置 UIScrollViewContentInsetAdjustmentAutomatic 将有助于前两项可触摸,但联系人列表的初始位置不正确。
- (IBAction)chooseFromContact:(id)sender {
if (@available(iOS 11.0, *)){
[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
ContactManager *contactManager = [ContactManager sharedInstance];
[contactManager selectContactAtController:self complection:^(NSString * _Nonnull phone) {
NSLog(@"Hello World");
}];
}
// in ContactManager.m
- (void)selectContactAtController:(UIViewController *)controller
complection:(void (^)(NSString *))completcion {
if (@available(iOS 11.0, *)){
[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentAutomatic];
}
self.contactPicker = [[CNContactPickerViewController alloc] init];
self.contactPicker.delegate = self;
[controller presentViewController:self.contactPicker animated:YES completion:nil];
self.currentViewController = controller;
self.didselectPhone = completcion;
}
预期结果:
实际结果: