IOS - 如何强制视图为横向
问题描述:
我想强制我的视图选择横向,就在我调用方法时.
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];
自转方法
- (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?
答
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];