0

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 ??

ikanimo
  • 481
  • 1
  • 4
  • 18

1 Answers1

1

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

Community
  • 1
  • 1
Rory McKinnel
  • 7,936
  • 2
  • 17
  • 28
  • no... I have try to comment the line **self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];** (Comment this out if it is there and rotation should start working.) but still have log of suppororientation called... but no orientation during app-life circle :( I can't figure out why – ikanimo Feb 13 '15 at 12:59
  • If your running on iOS8, that line should definitely be commented out as it stops rotation working at all and its nolonger required. Hangover from old xcode generation. Have you tried a build clean and rebuild? Always worth a try. – Rory McKinnel Feb 13 '15 at 14:01
  • I found out the error... it was My iPad3 ... I have restore it and now it works... maybe I have update iOs8 from iOS7... after a clean installation every rotation is right!! thank u all for the help!! – ikanimo Feb 14 '15 at 15:26