I think I have gone over almost every single post on this topic. So don't kill the question yet till you read. This question is for XCode 5 on iOS 7
I have an app that supports both landscape and portrait modes. In my projects Deployment info all orientations are checked.
When app launches I show
- v1ViewController (which always should open in landscape mode)
When a user hits a button it takes them to
- v3ViewController (which always should open in portrait mode)
The problem I have is that when app launches and I am holding the iphone in portrait mode it show this.
If I swtich the iphone in landscape mode it shows this.
How can I force my v1ViewController to always show landscape mode?
This is the code I have right now.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
return YES;
}
else
{
return NO;
}
}
But if I add this then the view always opens like the first picture I show and rotation has no effect.
- (BOOL)shouldAutorotate
{
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
NSLog(@"interfaceOrientation: %d ...", interfaceOrientation);
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
return YES;
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
return YES;
}
else
{
return NO;
}
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}