Search code examples
iosiphoneobjective-cuiinterfaceorientation

Support only portrait orientation


I need to support only portrait orientation in my app. How can I do it? I have tried adding

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>

and

 -(BOOL)     shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationPortrait;
}

But it does't help - the view rotates anyway.

Thanks in advance!


Solution

  • -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientationshould return a BOOL which is NOin your case.