gpt4 book ai didi

ios6 - 如何在仅在 iOS-6 中支持横向方向的应用程序中使用 UIImagePickerController?

转载 作者:行者123 更新时间:2023-12-01 08:34:50 25 4
gpt4 key购买 nike

我正在开发一个仅支持横向方向的应用程序。它使用 UIImagePickerController 从库中选择图像和/或视频。应用程序在 iOS-5 或更早版本中运行良好,但当我尝试呈现图像选择器 Controller 时它会崩溃。崩溃后会显示以下消息:

* 由于未捕获的异常“UIApplicationInvalidInterfaceOrientation”而终止应用程序,原因:“支持的方向与应用程序没有共同的方向,并且 shouldAutorotate 正在返回 YES”

最佳答案

正如@rocky 所说,您必须在应用程序中添加 Potrait 模式才能使用 UIImagePickerController 像这样

Supported Interface Orientation in Info.plist或者将此添加到您的仅限横向应用程序委托(delegate)类中

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskAll;
}

来自 Mr.Daniel's Answer我为您的 Landscape only App 找到了一个不错的解决方案,由于您只需要为您的应用程序支持横向,因此您只需要像这样为 UINavigationController 添加一个类别

@implementation UINavigationController (LandscapeOnly)

- (NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
@end

并将其添加到您的 viewControllers 中,它对我有用。

关于ios6 - 如何在仅在 iOS-6 中支持横向方向的应用程序中使用 UIImagePickerController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12859771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com