Xcode 4.5: SupportedInterfaceOrientation is not working

215 views Asked by At

I am using iOS 5 and XCode 4.2. After coding I gave support for landscape and portrait orientation. It is working correctly. But the orientation is not supported when I used the code in XCode 4.5 iOS 6.

Do anyone know the reason?

2

There are 2 answers

5
icodebuster On

Please check you project setting (Summary)

Supported Interface Orientation Setting for the allowed oreintations

enter image description here

OR

Try to lock the orientation using the following code:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown );
}
2
kalyani puvvada On

It correct way or not i don't know. But temporarily i used this method. If it useful you too can use.

You can write this method in your Appdelegate.

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
 [navigationController.topViewController shouldAutorotate];
 return UIInterfaceOrientationMaskAll;
}

You can write - (BOOL)shouldAutorotate method in your viewController.