IOS - How to force the view to landscape

♀尐吖头ヾ 提交于 2020-01-06 07:47:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!