Search code examples
iosobjective-cipadios7

ABPeoplePickerNavigationController and UIImagePickerController not displaying correctly on ipad iOS7


When I try use "ABPeoplePickerNavigationController" or "UIImagePickerController", in most cases it won't load up correctly. It will show part of the screen (transparent) starting in the middle of the screen in iOS 7 (ipad) for both simulator and device (screenshot below). In iOS 8 everything works correctly.

This is the code I use for ABPeoplePickerNavigationController:

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
self.preserveCurrentEntity = YES;
[self presentViewController:picker animated:NO completion:nil];

UIImagePickerController will break just for picking videos, but work for everything else, this is the code I use:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

switch (buttonIndex) {
    case ImagePickerModeCamera:
            imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        break;
    case ImagePickerModeAlbum:
        imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        break;
    default:
        break;
}
imagePicker.delegate = self;

NSMutableArray *mediaType = [[NSMutableArray alloc] init];

switch (self.actionSheetType) {
    case ActionSheetTypeImage:
        [mediaType addObject:(NSString*)kUTTypeImage];
        break;
    case ActionSheetTypeVideo: {
        [mediaType addObject:(NSString*)kUTTypeMovie];
        [mediaType addObject:(NSString*)kUTTypeVideo];
        imagePicker.allowsEditing =NO;
    }
        break;
    default:
        break;
}

imagePicker.mediaTypes = mediaType;
[self presentViewController:imagePicker animated:NO completion:nil];

This is what happens in iOS7 when loading ABPeoplePickerNavigationController:

iOS 7

This is what happens in iOS8 when loading ABPeoplePickerNavigationController:

iOS8

What is the solution to fix this?


Solution

  • Looks like I found the solution to my problem.

    I have a root view controller that has two xibs, one for iPad and one for iPhone. It seems my iPad one was causing the trouble even though they were very similar (just one was larger). I couldn't figure out why.

    I just use the iPhone one now and make sure it resizes correctly on iPad and everything is working correctly.