iOS 6中的UIImagePickerController无法正常工作
我有一个非常奇怪的行为:
- 在iOS 5中,我以这种方式呈现
UIImagePickerController
:
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
imagePicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:imagePicker animated:YES];
现在在iOS 6中,这会导致崩溃。 我通过在UIImagePickerController
上编写一个类来解决崩溃问题:
@implementation UIImagePickerController (NonRotating) - (BOOL)shouldAutorotate { return NO; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationMaskPortrait; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } @end
问题是,现在的UIImagePickerController
不旋转,它显示正面。 而且,当我按下“取消”button,选取器被解雇,应用程序再次崩溃。
- 如果我在
UIPopoverController
使用UIImagePickerController
,所有工作正常(属于UIPopoverController
不旋转的事实),但是当我closures在我的应用程序的popup窗口所有视图控制器停止响应旋转事件 ,这导致所有的应用程序被阻止在这个方向。 要恢复正确的行为,我需要从后台退出应用程序,然后再次打开。
这是我用来显示popover的代码
_cameraPopoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker]; [_cameraPopoverController presentPopoverFromRect:_takeFromCamera.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
这个问题让我疯狂!
什么是你的select器源types? 照片库/相册或相机胶卷?
假设你正在使用照片库/相册源,在iPad上,你必须使用一个popup窗口:
不支持全屏显示。
关于另一个问题(解散popOver后,其他VC停止旋转)检查你有一个强大的引用你的popover(强属性)。 粘贴您使用的代码来呈现popup窗口。
虽然我不build议使用该类别来覆盖图像select器的默认行为,但在实现中存在导致所述崩溃的错误:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationMaskPortrait; ~~~~ }
返回值不应该是一个方向掩码,它应该是一个方向,例如UIInterfaceOrientationPortrait。