Supported orientations has no common orientation with the application, and shoul

在調用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來支持具體的屏幕類型。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章