Rotate View That Gets Presented From Nav Controller

Discussion in 'iPhone/iPad Programming' started by newtoiphonesdk, Sep 15, 2012.

  1. macrumors 6502a

    Joined:
    Jul 30, 2010
    #1
    My root view is a Tab Bar Controller.

    In this tab view, I do not want any tabs to rotate. However, some of the Tab Bar Items are Navigation Controllers, that present different pdf documents. I would like those to rotate. However, I set the ViewController Classes for those views to return YES on shouldAutorotate method, yet they refuse to rotate.

    I present them using
    Code:
            [self.navigationController pushViewController:_webViewController animated:YES];
    
    _webViewController is allowed to rotate, but won't.

    I have also tried presenting Controller Modally, but that will not work either. Any thoughts?
     
  2. macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    Unless I'm mistaken, rotation limits are kind of inherited, aren't they?

    So if one view in the hierarchy can't have a certain rotation, anything under it also can't have that rotation. So either your tabs have to rotate or nothing can. I think. It seems like I had that issue a month or two ago and that was my finding.
     
  3. thread starter macrumors 6502a

    Joined:
    Jul 30, 2010
    #3
    Yet there are other apps that get by this like Twitter. In iPhone, if you click a tweet and then a URL in that tweet, a controller gets pushed that can rotate, while nothing else can.
     
  4. macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #4
    As I understand it, you want only certain elements to rotate while the tab bar it self stays in place. I do this in my CameraTime app. See the first two screen shots. Notice how the i and record buttons always are vertical.

    I learned the trick via Stackoverflow from this post. In case you are not taken to the best answer, the responder was Corey Floyd.

    The key is setting up the device to generate rotation notifications, listen for them, and act upon them.
    Code:
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
    When you do have rotation issues, it may be a good idea to review Why won't my UIViewController rotate with the device?

    Apple also has a WWDC 2012 video titled "Session 240 - Polishing Your Interface Rotations".
     

Share This Page