Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 860
Daniel Ryan Avatar asked Apr 12 '15 23:04

Daniel Ryan


2 Answers

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.

like image 106
Daniel Ryan Avatar answered Oct 21 '22 06:10

Daniel Ryan


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 !!

like image 28
Viral Savaj Avatar answered Oct 21 '22 06:10

Viral Savaj