iOS Error: Supported orientations has no common orientation with the application (iPhone)
iOS Error: Supported orientations has no common orientation with the application (iPhone)
使用iOS8.3
我有一个横向模式的视图,我正在尝试打开一个仅纵向视图控制器。每次我尝试打开它时,应用程序都会崩溃。
我读过这个official apple answer,它基本上建议执行以下操作:
在应用委托中:
@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
在项目常规设置中我有以下内容(根据苹果的回答应该不会改变):
我可以看到实际上正在调用这些函数,但没有任何帮助。
有什么想法吗?
我之前阅读的一些问题:
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'
概要: application(_:, supportedInterfaceOrientationsForWindow) -> Int
确实会覆盖常规 > 部署信息。因此,一旦您在应用程序委托中提供 supportedInterfaceOrientationsForWindow
,您就可以完全忽略该 .plist 。请参阅有关 UIInterfaceOrientationMaskPortrait
.
的注释
在 Obj-C 和 Swift 中以各种方式尝试了上面的代码,我唯一一次得到...
'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [ViewController shouldAutorotate] is returning YES'
...是什么时候:
- 使用
UIInterfaceOrientationPortrait
代替UIInterfaceOrientationMaskPortrait
(mask是这里的关键词)
- 或
supportedInterfaceOrientations
returns 未 supportedInterfaceOrientationsForWindow
中列出的掩码
A. 将此块放在 class 采用 UIApplicationDelegate
协议(通常是 AppDelegate.m
或 AppDelegate.swift
) :
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return UIInterfaceOrientationMaskAll;
else /* iphone */
return UIInterfaceOrientationMaskAllButUpsideDown;
}
supportedInterfaceOrientations
将覆盖 部署信息 并允许在运行时动态区分 iPhone 和 iPad。
B. 将此块放置在 UIViewController
subclass 中,您希望其具有特定的行为(通常是 CustomViewController.m
或 CustomViewController.swift
):
Obj-C
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Swift
override func supportedInterfaceOrientations() -> Int {
let supported = UIInterfaceOrientationMask.Portrait.rawValue
return Int(supported)
}
测试iOS8.4
呃,对我来说,这是我颤抖中的这条线main.dart让我感到震惊:
await SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
使用iOS8.3
我有一个横向模式的视图,我正在尝试打开一个仅纵向视图控制器。每次我尝试打开它时,应用程序都会崩溃。
我读过这个official apple answer,它基本上建议执行以下操作:
在应用委托中:
@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
在项目常规设置中我有以下内容(根据苹果的回答应该不会改变):
我可以看到实际上正在调用这些函数,但没有任何帮助。 有什么想法吗?
我之前阅读的一些问题:
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'
概要: application(_:, supportedInterfaceOrientationsForWindow) -> Int
确实会覆盖常规 > 部署信息。因此,一旦您在应用程序委托中提供 supportedInterfaceOrientationsForWindow
,您就可以完全忽略该 .plist 。请参阅有关 UIInterfaceOrientationMaskPortrait
.
在 Obj-C 和 Swift 中以各种方式尝试了上面的代码,我唯一一次得到...
'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [ViewController shouldAutorotate] is returning YES'
...是什么时候:
- 使用
UIInterfaceOrientationPortrait
代替UIInterfaceOrientationMaskPortrait
(mask是这里的关键词) - 或
supportedInterfaceOrientations
returns 未supportedInterfaceOrientationsForWindow
中列出的掩码
A. 将此块放在 class 采用 UIApplicationDelegate
协议(通常是 AppDelegate.m
或 AppDelegate.swift
) :
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return UIInterfaceOrientationMaskAll;
else /* iphone */
return UIInterfaceOrientationMaskAllButUpsideDown;
}
supportedInterfaceOrientations
将覆盖 部署信息 并允许在运行时动态区分 iPhone 和 iPad。
B. 将此块放置在 UIViewController
subclass 中,您希望其具有特定的行为(通常是 CustomViewController.m
或 CustomViewController.swift
):
Obj-C
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Swift
override func supportedInterfaceOrientations() -> Int {
let supported = UIInterfaceOrientationMask.Portrait.rawValue
return Int(supported)
}
测试iOS8.4
呃,对我来说,这是我颤抖中的这条线main.dart让我感到震惊:
await SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);