• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iPhone/iPad device orientation problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iPhone/iPad device orientation problems


  • Subject: Re: iPhone/iPad device orientation problems
  • From: David Duncan <email@hidden>
  • Date: Thu, 14 Oct 2010 09:30:15 -0700

On Oct 13, 2010, at 10:36 PM, Philip Mobley wrote:

> In your UIViewController write something like this (example below is to force the app into landscape mode only):
>
> // Override to allow orientations other than the default portrait orientation.
> - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
>    // Return YES for supported orientations
>
> 	if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
> 		[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
> 		return YES;
> 	} else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
> 		[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
> 		return YES;
> 	}
>
> 	return NO;
> }


There should be no reason (or need) to set the status bar orientation in the code above. Just return YES if the requested rotation is landscape, like the below:

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

As a rule -shouldAutorotateToInterfaceOrientation: should not have any side effects, primarily because it may be called in situations other than when your view controller currently arbitrates the supported orientations (most commonly this case is a UITabBarController).
--
David Duncan

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >iPhone/iPad device orientation problems (From: William Squires <email@hidden>)
 >Re: iPhone/iPad device orientation problems (From: Philip Mobley <email@hidden>)

  • Prev by Date: Re: Tableview similar to the network preferences in snowleopard
  • Next by Date: Missing something with CGColorGetComponents()
  • Previous by thread: Re: iPhone/iPad device orientation problems
  • Next by thread: Text Tables created programatically don't play nice with standard table UI
  • Index(es):
    • Date
    • Thread