Rotate View That Gets Presented From Nav Controller

Discussion in 'iOS Programming' started by newtoiphonesdk, Sep 15, 2012.

  1. newtoiphonesdk macrumors 6502a

    Jul 30, 2010
    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
            [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. ArtOfWarfare macrumors G3


    Nov 26, 2007
    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. newtoiphonesdk thread starter macrumors 6502a

    Jul 30, 2010
    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. xStep macrumors 68000

    Jan 28, 2003
    Less lost in L.A.
    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.
    [[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