Reputation: 4050
I have a app that has 5.0 as deployment target and 6.1 as base sdk and it all works great on a iOS 6.x device/simulator. But on 5.x my views are not rotating. I have googled around and found some Stackoverflow post on this, but I cant quite find heads and tails in it all. I think I need to implement my own subclasses of the different view controllers I use, but which and am I right?
In my app delegate didFinishLaunchingWithOptions
I use this to create my app:
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1, viewController2, viewController3];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
I create my viewController1.. like this:
viewController1 = [[UINavigationController alloc] initWithRootViewController:[[SearchVC alloc] initWithNibName:@"SearchVC_iPhone" bundle:nil]];
I have tried implementing shouldAutorotateToInterfaceOrientation
in my SearchVC_iPhone view controller and I have tried subclassing UINavigationController
and implementing shouldAutorotateToInterfaceOrientation
in that subclass also but it is not working out for me and I am really just guessing here.
Please can anyone who knows this stuff help me out here, what do I need to do to get this working in iOS 5.x also?
Thank you
Søren
Upvotes: 1
Views: 747
Reputation: 4050
I solved it!! The problem is the rootViewController, I have to implement shouldAutorotateToInterfaceOrientation on the rootViewController and then all subviews starts behaving as they should. So I made my own UITabBarController subclass that implements shouldAutorotateToInterfaceOrientation and set that as the rootViewController.
Upvotes: 1
Reputation: 5
I'm working on an application (Xcode 4.5 iOS 6), it must be compatible for the devices that have installed software version, starting at 4.5 and default iPhone 5.
I know that the new iOS 6 changes came with the auto-rotate mode.
When you turn on your device "iPhone Simulator 6.0" application behaves normally but when I run the "iPhone Simulator 5.0" problems in the way of rotation.
I put in the code, along with new ways to rotate from iOS 6 and the old method (deprecated) to iOS 5.
So look for the rotate methods:
#pragma mark - Rotate Methods iOS 5
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
//Code Here
}
if (UIInterfaceOrientationIsLandscape(interfaceOrientation))
{
//Code Here
}
return YES;
}
#pragma mark - Rotate Methods iOS 6
(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation))
{
//Code here
}
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
{
//Code here
}
}
Upvotes: 0
Reputation: 463
In IOS5 you may use
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
In IOS6 you may use
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
Upvotes: 2