简体   繁体   中英

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?

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.

I have the same problem like you, but after wasting some time I got some post, that what may be the reason in your case.

iPhone Library does not work on the iOS Simulator in special case of picking Vedio

Referred Post for my solution. and worked for me.

Update on it, if you still facing problem, I can post my code to help you.

HTH, Enjoy Coding !!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM