1
votes

I am developing an iPhone only app. This application supports portrait and landscape orientations in the Supported Interface Orientations, but in the first view of the application I disable rotation with the following code:

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

Now, my problem is that when I start the app on an iPad with iOS 6.1 while holding the iPad in landscape mode, the app starts in portrait mode while the status bar is in landscape mode. Also, the application does not respond to any touches.

I have tried returning YES in the call to shouldAutorotate or setting the status bar in portrait mode with a call to [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait], BUT when I do this the application switches 3 times in orientation (landscape -> portrait upsidedown -> portrait) resulting in a lot of flickering at start-up, so this doesn't seem like the way to go, or is it?

1

1 Answers

1
votes

What you have in AppDelegate function

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ }

By default, an app and a view controller’s supported interface orientations are set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom.

Check for selected viewcontroller in supportedInterfaceOrientationsForWindow function and then set it to Portrait orientation.