0

I have two view controllers, foo that is portrait only and bar that is portrait + landscape. When I push bar onto foo, foo always starts in portrait orientation. The user needs to tilt the phone after the push to get the os to detect the new orientation. What I would prefer is foo to be in landscape from the moment it is loaded, if the phone is landscape the moment it is pushed.

How could this be achieved on iOS6 and 7 both?

Morrowless
  • 6,856
  • 11
  • 51
  • 81

1 Answers1

0

I would add this code

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Adapt the orientation with your need
    return (interfaceOrientation != UIInterfaceOrientationPortrait &&
            interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (BOOL)shouldAutorotate {
    UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];

    if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
       return YES;
    else
       return NO;
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscapeLeft;
}
Pull
  • 2,236
  • 2
  • 16
  • 32
  • Did you try this? http://stackoverflow.com/questions/14402401/viewcontroller-in-uinavigationcontroller-orientation-change – Devangi Desai Dec 17 '13 at 09:23
  • http://stackoverflow.com/questions/14633213/force-portrait-orientation-while-pushing-from-landscape-view-controller - try this too – Devangi Desai Dec 17 '13 at 09:25
  • If I understand correctly, you want to support both landscape and portrait, but you want also the view to appear landscape if the phone is in landscape mode ? If so, have you try to put some condition ? I edit my answer – Pull Dec 17 '13 at 09:26
  • I see that this question is still open, did you find a solution ? – Pull Dec 18 '13 at 15:13