项目是在ipad上的横屏的项目,运行在ios6上时,在用到选择本地相册的时候崩溃:
“Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES”
一查原来是ios6的rotation较之前有了改动。ios6丢弃了shouldAutorotateToInterfaceOrientation的方法,代替的是supportedInterfaceOrientations 、shouldAutorotate 、preferredInterfaceOrientationForPresentation等方法,具体变化见:iOS 6的Rotation
因为项目要求是全部横屏,但是UIImagePickerController又是竖屏显示的。违反了ios6对Rotation的新规定。最终在http://code4app.com/requirement/5074e36b6803fa8445000000
找到答案。
在appdelegate添加
#if __IPAD_OS_VERSION_MAX_ALLOWED >= __IPAD_6_0
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationAllMask;
}
#endif
然后在你UIImagePickerController的top-most VC中添加:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft||interfaceOrientation==UIInterfaceOrientationLandscapeRight);
}
//ios 6 rotation
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationLandscapeMask;
}
- (BOOL)shouldAutorotate
{
return YES;
}
问题解决!
本文转自老Zhan博客园博客,原文链接:http://www.cnblogs.com/mybkn/archive/2012/11/05/2755716.html,如需转载请自行联系原作者