UIImagePickerController is not presenting correctl

2019-05-11 14:29发布

I'd like to present an UIImagePickerController with the following code:

self.pickerController = [[UIImagePickerController alloc] init];
self.pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.pickerController.delegate = self;

[self presentViewController:self.pickerController animated:YES completion:nil];

It's working fine for iOS 7 and below, but in iOS 8 I got the following glitch:

  1. While transitioning to the image picker controller (vertical cover animation), the background colour of the picker controller is invisible, revealing the presenting view controller beneath. After transition is finished, the picker's table view will be displayed abruptly without animation.

  2. Sometimes, the picker's table view is not displayed at all, and instead I got a blank black screen. The navigation bar is still there, but no bar button items whatsoever, so user has to force quit the application.

Anyone know what's going on here?

1条回答
聊天终结者
2楼-- · 2019-05-11 14:55

So I managed to find the cause and fix for these problems and want to document it here:

  1. The first problem occurred when I tried to compile to iOS 8 device from XCode 5.1. I switched to XCode 6 beta 2 and now it's working just fine.

  2. The second problem occurred when I tried to reuse an UIImagePickerController that has been displayed before. Create a new instance instead before displaying, and it would be fixed.

Cheers.

查看更多
登录 后发表回答