IOS error: supported orientations do not have a common orientation with the application (iPhone)

Using iOS 8.3

I have a view in landscape mode and I'm trying to open the view manager for portrait only. every time I try to open it, the application crashes.

I read this official answer on Apple , which basically recommends doing the following:

in the application delegate:

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

and in my controller:

 -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } 

And so I have, and yet I still get this error message:

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

In the general settings of the project, I have the following (which should not be changed in accordance with the answer of the apple):

settings

I see that these functions are actually being called, but nothing helps. Any thoughts?

Some questions I read earlier:

How to force UIViewController to portrait orientation in iOS 6

iOS6: supportedInterfaceOrientations not working (called, but the interface still rotates)

Supported orientations do not have a common orientation with the application, and shouldAutorotate returns YES '

+4
source share
1 answer

Summary: application(_:, supportedInterfaceOrientationsForWindow) -> Int overwrites General> Deployment Information. This way you can ignore this .plist completely once you provide the supportedInterfaceOrientationsForWindow in the application delegate. See Note to UIInterfaceOrientationMaskPortrait .

Having tried the code above each method, both in Obj-C and Swift, only the time I get ...

'UIApplicationInvalidInterfaceOrientation', reason: "Supported orientations do not have a common orientation with the application, and [ViewController shouldAutorotate] returns YES '

... is when:

  • using UIInterfaceOrientationPortrait instead of UIInterfaceOrientationMaskPortrait ( mask is the keyword here)
  • or supportedInterfaceOrientations returns the mask not specified in supportedInterfaceOrientationsForWindow

A. Place this block in the class using the UIApplicationDelegate protocol (usually AppDelegate.m or AppDelegate.swift ):

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

supportedInterfaceOrientations overwrites deployment information and dynamically distinguishes iPhone from iPad at run time.


B. Place this block in a subclass of UIViewController that requires a specific behavior (usually CustomViewController.m or CustomViewController.swift ):

Obj-c

 -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 

Swift

 override func supportedInterfaceOrientations() -> Int { let supported = UIInterfaceOrientationMask.Portrait.rawValue return Int(supported) } 

Tested iOS 8.4

+8
source

All Articles