disable autorotate on a single UIViewController in iOS6

Per the View Controller Programing Guide If you want to temporarily disable automatic rotation, avoid manipulating the orientation masks to do this. Instead, override the shouldAutorotate method on the initial view controller. This method is called before performing any autorotation. If it returns NO, then the rotation is suppressed. So you need to subclass ‘UINavigationController’, … Read more

Mobile site – force landscape only / no auto-rotate

Use media queries to test the orientation, in the portrait stylesheet hide everything and show a message that the app only works on landscape mode. <link rel=”stylesheet” type=”text/css” href=”https://stackoverflow.com/questions/10975387/css/style_l.css” media=”screen and (orientation: landscape)”> <link rel=”stylesheet” type=”text/css” href=”css/style_p.css” media=”screen and (orientation: portrait)”> I think is best aproach

How to make app fully working correctly for autorotation in iOS 6?

Figured it out. 1) subclassed UINavigationController (the top viewcontroller of the hierarchy will take control of the orientation.) did set it as self.window.rootViewController. – (BOOL)shouldAutorotate { return self.topViewController.shouldAutorotate; } – (NSUInteger)supportedInterfaceOrientations { return self.topViewController.supportedInterfaceOrientations; } 2) if you don’t want view controller rotate – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } -(BOOL)shouldAutorotate { return NO; … Read more

How to force view controller orientation in iOS 8?

For iOS 7 – 10: Objective-C: [[UIDevice currentDevice] setValue:@(UIInterfaceOrientationLandscapeLeft) forKey:@”orientation”]; [UINavigationController attemptRotationToDeviceOrientation]; Swift 3: let value = UIInterfaceOrientation.landscapeLeft.rawValue UIDevice.current.setValue(value, forKey: “orientation”) UINavigationController.attemptRotationToDeviceOrientation() Just call it in – viewDidAppear: of the presented view controller.