Re: iPhone/iPad device orientation problems
Re: iPhone/iPad device orientation problems
- Subject: Re: iPhone/iPad device orientation problems
- From: Philip Mobley <email@hidden>
- Date: Wed, 13 Oct 2010 22:36:47 -0700
On Oct 13, 2010, at 7:16 PM, William Squires wrote:
> Hi
> What's the proper way to force an iOS device to set the orientation to one of
>
> UIInterfaceOrientationLandscapeLeft
> UIInterfaceOrientationLandscapeRight
> UIInterfaceOrientationPortrait
> UIInterfaceOrientationPortraitUpsideDown
>
> ?
>
> So what is the correct way of programmatically setting the interface orientation in iOS devices?
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;
}
_______________________________________________
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