Rotation behaving differently on iOS6
The most important part of the documentation I found for this issue is:
When the user changes the device orientation, the system calls this
method on the root view controller or the topmost presented view
controller that fills the window
To make my app fully working for autorotation in iOS 6, I had to do the following:
1) I created a new subclass of UINavigationController, and added shouldAutorotate and supportedInterfaceOrientation methods:
// MyNavigationController.h:
#import <UIKit/UIKit.h>
@interface MyNavigationController : UINavigationController
@end
// MyNavigationController.m:
#import "MyNavigationController.h"
@implementation MyNavigationController
...
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
...
@end
2) In the AppDelegate, I did use my new subclass to show my root ViewController (it is introScreenViewController, a UIViewController subclass) and did set the self.window.rootViewController, so it looks that:
nvc = [[MyNavigationController alloc] initWithRootViewController:introScreenViewController];
nvc.navigationBarHidden = YES;
self.window.rootViewController = nvc;
[window addSubview:nvc.view];
[window makeKeyAndVisible];
Rotation behaving differently on iOS6
The most important part of the documentation I found for this issue is:
When the user changes the device orientation, the system calls this
method on the root view controller or the topmost presented view
controller that fills the window
To make my app fully working for autorotation in iOS 6, I had to do the following:
1) I created a new subclass of UINavigationController, and added shouldAutorotate and supportedInterfaceOrientation methods:
// MyNavigationController.h:
#import <UIKit/UIKit.h>
@interface MyNavigationController : UINavigationController
@end
// MyNavigationController.m:
#import "MyNavigationController.h"
@implementation MyNavigationController
...
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
...
@end
2) In the AppDelegate, I did use my new subclass to show my root ViewController (it is introScreenViewController, a UIViewController subclass) and did set the self.window.rootViewController, so it looks that:
nvc = [[MyNavigationController alloc] initWithRootViewController:introScreenViewController];
nvc.navigationBarHidden = YES;
self.window.rootViewController = nvc;
[window addSubview:nvc.view];
[window makeKeyAndVisible];
Support different orientation for only one view iOS 6
This worked for me How to force a UIViewController to Portrait orientation in iOS 6
Create a new category from UINavigationController overriding the rotating methods:
-(BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.topViewController preferredInterfaceOrientationForPresentation];
}
@end
Related Topics
Swift - Get Local Date and Time
Xcode 10.2 with Swift 5.0 Compiler - Protocol Inheritance Issue
Right Way of Determining Internet Speed in iOS 8
Preferredinterfaceorientationforpresentation Must Return a Supported Interface Orientation
Xcode iOS Project Only Shows "My MAC 64-Bit" But Not Simulator or Device
Programmatically Scroll a Uiscrollview
Libraries Not Found When Using Cocoapods with iOS Logic Tests
Ios: Launch Image Multiple Language
Indexpathforcell Returns Nil Since iOS7
iOS 9 Segue Causes App to Freeze (No Crash or Error Thrown)
Core Data Multi Thread Application
How to Disable Floating Headers in Uitableview with Uitableviewstyleplain
Uipangesturerecognizer - Only Vertical or Horizontal
Screenshot Showing Up Blank - Swift
What Is Kcferrordomaincfnetwork Code=303
Iphone:Daily Local Notifications
Swift 4 "This Class Is Not Key Value Coding Compliant"
Recording to Aac from Remoteio: Data Is Getting Written But File Unplayable