Reputation: 491
I have a Navigation Controller with this:
//=========================
- (BOOL)shouldAutorotate;
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
NSLog(@"Nav: supported Orientation");
if ([[self topViewController] respondsToSelector:@selector(supportedInterfaceOrientations)])
else
return [super supportedInterfaceOrientations];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[self.topViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[self.topViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
MY ROOTCTRL has:
//=========================
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}
-(BOOL)shouldAutorotate
{
return YES;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
NSString *risp;
switch (self.interfaceOrientation) {
case UIInterfaceOrientationLandscapeLeft:
risp = @"LAND_LEFT";
break;
case UIInterfaceOrientationLandscapeRight:
risp = @"LAND_RIGHT";
break;
case UIInterfaceOrientationPortrait:
risp = @"PORT";
break;
case UIInterfaceOrientationPortraitUpsideDown:
risp = @"PORT_UPsideDOWN";
break;
case UIInterfaceOrientationUnknown:
risp = @"UNKNOW";
break;
default:
break;
}
NSLog(@"HOME didRotate:%@",risp);
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
}
supportedInterfaceOrientations of UINavigationController is always called, supportedInterfaceOrientations of Home controller is always called too; but Home doesn't rotate from LANDSCAPE LEFT to LANDSCAPE RIGHT and viceversa:
So Home ctrl has the right orientation at launching, but if device did rotate Home controller NEVER rotate... it's only called supportedInterfaceOrientations method (both nav controller and root controller) with no effect...
What Am I doing wrong ??
Upvotes: 0
Views: 548
Reputation: 8014
If running on iOS8 and your code has been around since before iOS8, check the following answer. Delete the line mentioned in your app delegate if it exists and it should start working.
UISplitViewController rotation iOS8 not working as expected
Upvotes: 1