I have a navigation controller and it goes through that in portrait. Then, at a certain point, I push to a view that displays a graph, which I want to only display in landscape, and not even be in portrait at all (this screws up how the view looks).
In this view, GraphViewController, I have the following method:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
When the view first gets pushed, it appears in portrait mode. If I rotate the phone, the view will rotate into landscape also (not upside down portrait). But I want it to not even ever be in portrait mode, not even when it starts. I have verified that this method is getting called by adding a NSLog.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
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.