I dont know why the device orientation doesn't work.
In the project properties:
In my code I have:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationPortrait) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(interfaceOrientation ==UIInterfaceOrientationLandscapeRight));
}
I probe it in my iphone and doesn't change.
Is something missing?
Thank you in advance
Edited (info.plist)
Open your info.plist
file in XCode
and add a line - Supported interface orientation
of type array.
Hit the plus button next to it and list all orientations you want to use. You can set different settings for iPhone
and iPad
.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if((interfaceOrientation == UIInterfaceOrientationPortrait) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeLeft)||
(interfaceOrientation == UIInterfaceOrientationLandscapeRight))
{
return YES;
}
return NO;
}
Where in your code is shouldAutorotateToInterfaceOrientation:
implemented? It should be a method of each and every subclass of UIViewController
.
Try making sure that it's working by putting a log statement or breakpoint in shouldAutorotateToInterfaceOrientation:
. If it's not being called, a view controller somewhere else is deciding your valid orientations for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.