如何在仅支持iOS-6横向方向的应用程序中使用UIImagePickerController? [英] how to use UIImagePickerController in an app which support Landscape orientation only in iOS-6?
问题描述
我正在开发一款仅支持横向定位的应用。它使用 UIImagePickerController
从库中选择图像和/或视频。应用程序在iOS-5或之前运行良好但在我尝试呈现图像选择器控制器时它会崩溃。它在崩溃后发出以下消息:
I am developing an app which supports Landscape orientation only. It uses an UIImagePickerController
to pick images and/or videos from the library. App is functioning fine in iOS-5 or before but it gets crashed when I try to present image picker controller.It gives the following message after crashing:
* 由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'而终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'
* Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
推荐答案
正如@rocky所说,你必须在你的应用程序中添加Potrait模式才能使用 UIImagePickerController
喜欢这个
As @rocky said you have to add Potrait mode to your application to use UIImagePickerController
Like this
或
将此添加到您的仅横向app委托类
or add this to your landscape only app delegate class
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskAll;
}
和丹尼尔先生的答案 我为您的仅景观应用程序找到了一个很好的解决方案,
,因为您只需要支持应用程序的景观,您只需要为添加类别UINavigationController
像这样
@implementation UINavigationController (LandscapeOnly)
- (NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
@end
并将其添加到viewControllers,它适用于我。
and add this to your viewControllers, it works for me.
这篇关于如何在仅支持iOS-6横向方向的应用程序中使用UIImagePickerController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!