iOS错误:支持的方向与应用程序(iPhone)没有共同的方向

时间:2015-08-23 17:06:57

标签: ios objective-c iphone uiimagepickercontroller

使用iOS 8.3

我在横向模式下有一个视图,我试图打开一个仅限肖像的视图控制器。每当我尝试打开它时,应用程序都会崩溃。

我已阅读此official apple answer,基本上建议您执行以下操作:

在app delegate中:

@implementation AppDelegate

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return UIInterfaceOrientationMaskAll;
    else  /* iphone */
        return UIInterfaceOrientationMaskAllButUpsideDown;
} 

并在我的控制器中:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

所以我有,但我仍然得到这个崩溃消息:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES

在项目常规设置中,我有以下内容(不应根据苹果答案进行更改):

settings

我可以看到这些函数实际上被调用但没有任何帮助。 有什么想法吗?

我之前读过的一些问题:

How to force a UIViewController to Portrait orientation in iOS 6

iOS6: supportedInterfaceOrientations not working (is invoked but the interface still rotates)

Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

1 个答案:

答案 0 :(得分:0)

呃,对我来说,我的 flutter main.dart 中的这一行让我大吃一惊:

  await SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);