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