When I click the back button my view changes from landscape to portrait

江枫思渺然 提交于 2019-12-11 19:34:49

问题


I am using storyboard and have my app set to be only horizontal left and right. I have a view controller where I click to go to my next view and do whatever, and when I am done I click the back button. What happens is when I click the back button the horizontal view switches to portrait and messes my whole app up. I have my segues set as push, but I did have them at modal.

Then it goes to my next screen

When I click back, it for some reason switches to portrait and looks like this:

I have no idea why it would do this... Has anybody else had this problem or have an idea of whats going on???


回答1:


You need to go through and set your rootViewController's orientation to landscape only. Then make sure all other viewControllers orientations are set to inferred.

It is also a good idea if you haven't already to go into your info.plist and make sure you have supported only landscape orientations.

Also you may need to add some code to your viewControllers that looks something like this:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}


来源:https://stackoverflow.com/questions/11798808/when-i-click-the-back-button-my-view-changes-from-landscape-to-portrait

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