iOS|iOS 横屏中添加UIImagePickerController获取系统图片

迁移自开源中国

  1. 在完全横屏的应用中(Supported interface orientations只有两个选项Landscape (right home button)和Landscape (left home button))。
  2. 添加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默认只支持竖屏的原因
【iOS|iOS 横屏中添加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

    推荐阅读