iOS 横屏中添加UIImagePickerController
2017-02-15 本文已影响41人
liyc_dev
迁移自开源中国
- 在完全横屏的应用中(Supported interface orientations只有两个选项Landscape (right home button)和Landscape (left home button))。
- 添加UIImagePickerController来获取系统图片和拍照时崩溃
2014-03-25 10:11:37.697 beethoven-new iOS[1372:60b] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
产生原因:UIImagePickerController默认只支持竖屏的原因
如何解决
添加UIImagePickerController分类LandScapeImagePicker
@interface UIImagePickerController (LandScapeImagePicker)
- (BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations;
@end
#import "UIImagePickerController+LandScapeImagePicker.h"
@implementation UIImagePickerController (LandScapeImagePicker)
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
@end