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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to