0
votes
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
        return NO;
} else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        return NO;
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        NSLog(@"Landscape left detected!");
        return NO;
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        NSLog(@"Landscape right detected!");
        return YES;
}

I am trying to implement an iPad app having landscape mode only. I set the Supported interface orientations as Landscape right mode in info.plist. WHen the application is started, the view is in Landscape mode itself. But when i added another view, such as Home view, after login, view is not rotated as landscape. It was in portrait mode. In the xib file also, i set it as landscape. I have included the above code in both Login and Home view controller. But the home view is not rotating after login.

2

2 Answers

0
votes

First you dont have to write checks for each and every orientation. You can achieve this by simply using the following code in your viewController's shouldAutorotateToInterfaceOrientation method

return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

Second can you provide more details on how actually you are adding more views. It will be more helpful to find the problem.

0
votes

do this in each view controller

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
}