Question

i am getting a strange problem in my iPhone app. I want my app to support ONLY portrait mode, but for some reason I can't do it (device & simulator).

To support only portrait mode I did as follow:

In the TARGET summary section on Xcode, I chose only portrait.
All my ViewControllers implements shouldAutorotateToInterfaceOrientation

But as I said it won't work, and the strange result is that the app support ALL the orientations (portrait, upside down, landscape left, landscape right). Any ideas?

this how I implement shouldAutorotateToInterfaceOrientation

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     // Return YES for supported orientations
     NSLog(@"Checking orientation %d", interfaceOrientation);
     return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

Many thanks in advance.

Was it helpful?

Solution

Try this Sir,

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

Hope It helps. Thanks :)

OTHER TIPS

set the key "Supported interface orientations (iPhone)" with which orientation you want in info.plist file of your app.

Here I am using only Landscape you can use Portrait.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top