CNContactPickerViewController contact list offset issue

87 Views Asked by At

Description: If I set "[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];" somewhere else in my app, the first two items in CNContactPicerViewController will be coverd and cannot be touched. Setting UIScrollViewContentInsetAdjustmentAutomatic back before present Contact Picer will help the first two items to be touchable, but the initial position of the contact list is incorrect.

- (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;
}

Expected result:

enter image description here

Actual result:

enter image description here

0

There are 0 best solutions below