支持的方向与应用程序没有共同的方向,shouldAutorotate 返回 YES' [英] Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

查看:30
本文介绍了支持的方向与应用程序没有共同的方向,shouldAutorotate 返回 YES'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序 (iPad;iOS 6) 是仅限横向的应用程序,但是当我尝试使用 UIPopoverController 显示照片库时,它会引发此错误:支持的方向与应用程序没有共同的方向,shouldAutorotate 返回 YES. 我尝试更改了很多代码,但我没有运气.

My app (iPad;iOS 6) is a landscape only application, but when I try using a UIPopoverController to display the photo library it throws this error: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES. I've tried changing a lot of the code around but I've had no luck.

推荐答案

在 IOS6 中,您在三个地方支持界面方向:

In IOS6 you have supported interface orientations in three places:

  1. .plist(或目标摘要屏幕)
  2. 您的 UIApplicationDelegate
  3. 正在显示的 UIViewController

如果您收到此错误,很可能是因为您在 UIPopover 中加载的视图仅支持纵向模式.这可能是由 Game Center、iAd 或您自己的观点引起的.

If you are getting this error it is most likely because the view you are loading in your UIPopover only supports portrait mode. This can be caused by Game Center, iAd, or your own view.

如果它是您自己的视图,您可以通过覆盖 UIViewController 上的 supportedInterfaceOrientations 来修复它:

If it is your own view, you can fix it by overriding supportedInterfaceOrientations on your UIViewController:

- (NSUInteger) supportedInterfaceOrientations
{
     //Because your app is only landscape, your view controller for the view in your
     // popover needs to support only landscape
     return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

如果不是你自己的视图(比如iPhone上的GameCenter),你需要确保你的.plist支持竖屏模式.您还需要确保您的 UIApplicationDelegate 支持以纵向模式显示的视图.您可以通过编辑 .plist 然后覆盖 UIApplicationDelegate 上的 supportedInterfaceOrientation 来完成此操作:

If it is not your own view (such as GameCenter on the iPhone), you need to make sure your .plist supports portrait mode. You also need to make sure your UIApplicationDelegate supports views that are displayed in portrait mode. You can do this by editing your .plist and then overriding the supportedInterfaceOrientation on your UIApplicationDelegate:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

这篇关于支持的方向与应用程序没有共同的方向,shouldAutorotate 返回 YES'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆