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默认只支持竖屏的原因。

解决:

添加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



在对应位置应用就可以了

你可能感兴趣的:(ios,崩溃,横屏)