问题
I want to force my view to go for landscape, just when I call a method.
When my method runs I call:
[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)UIInterfaceOrientationLandscapeRight];
Method to autorotate
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
The problem is that the view don't force the rotation. Is possible to test it on the simulator, or just works in real device?
回答1:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
来源:https://stackoverflow.com/questions/11037817/ios-how-to-force-the-view-to-landscape