iOS force landscape in one viewController

我是研究僧i 提交于 2019-12-06 16:07:53
Hermann Klecker

There is one trick that really works. You can access the status bar and set its orientation. That becomes active next time a view is displayed modally. However, right after displaying modally you can remove the modally displayed veiw controller. When you do that within the same method, then the user would not noticing anyhing. Now the device has the desired orientation. You can now safely push the view controller that you want to be in another orientation.

Do not forget to rotate it back, when returning from that view controller!

See the answer to this question. It comes with some code sniplets. Force controllers to Change their orientation in Either Portrait or Landscape

Mrugesh Tank

If you want to disable or enable specific orientation in some view controller then this might be helpful to you.

And if you want to open some view in specific orientation then use this in viewDidLoad

NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!