在调用 UIImagePickerController 显示图片库的时候,显示如题的错误。
后面发现论坛上有这个问题的解决方法,记录如下:
1. 在AppDelegate里面添加这个方法就OK了
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskAll;
}
#endif
如果程序不是只支持横屏,而是横屏竖屏都支持的,那么就 到1 就可以解决了。但是,如果程序只支持横屏,这个解决方法就会导致一个问题:
所有的界面都可以支持竖屏了,这个不是我们想要的,那么就需要添加下面的步骤。
2 . 从
UINavigationController
派生出一个 自己的类 MyRootViewController:
类里面加上这么几个方法:
-(NSUInteger)supportedInterfaceOrientations
{
returnUIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate {
return YES;
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIDeviceOrientationLandscapeLeft ||
interfaceOrientation == UIDeviceOrientationLandscapeRight);
}
3. 找到appDelegate的 laugth方法中,替换为:
// Create a Navigation Controller with the Director
navController_ = [[MyRootViewControlleralloc] initWithRootViewController:director_];
navController_.navigationBarHidden =YES;
在.h文件中,将 navController_ 的定义 改为 MyRootViewController
4.到此,就完美解决了。感谢网络,感谢google .