在调用UIImagePickerController出现这个错误的解决办法:
Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
在Info.plist里需要设置程序支持Portrait,同时编写一个继承类继承UIImagePickerController。
@interface NonRotatingUIImagePickerController : UIImagePickerController
@end
@implementation NonRotatingUIImagePickerController
- (BOOL) shouldAutorotate
{
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
}
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
return UIInterfaceOrientationMaskAllButUpsideDown;
//return UIInterfaceOrientationMaskLandscape;
#endif
}
@end
原因是UIImagePickerController默认是竖屏,所以程序需要支持竖屏,然后通过自定义的controller来支持具体的屏幕类型。
本文提供了解决使用UIImagePickerController时遇到的竖屏不支持问题的方法,包括在Info.plist中设置程序支持Portrait,并通过自定义的controller来支持特定的屏幕类型。详细步骤如下:首先,在Info.plist中添加程序支持Portrait;其次,创建一个继承类继承UIImagePickerController,重写shouldAutorotate、shouldAutorotateToInterfaceOrientation和supportedInterfaceOrientations方法,以支持竖屏。
1万+

被折叠的 条评论
为什么被折叠?



