问题描述
我有一个应用程序,我正在改变屏幕方向。但是,当我更改第一个屏幕的方向并转到下一个屏幕时,更改不会持续存在。
I have an application in which I am changing screen orientation. But when I change orientation for the first screen and go to the next screen, the change does not persist.
附上图片以便更清楚地理解。
Attached are images for clearer understanding.
主要问题是当设备旋转时,第一个屏幕会旋转,但第二个屏幕不会以新的方向启动。
只有当我们旋转时它才会旋转屏幕启动后更改方向。
The main problem is that when device is rotated then first screen rotates but second does not launch in the new orientation.
It will rotate only when we change orientation after the screen is launched.
我如何解决这个问题?
推荐答案
问题在于当你旋转设备然后
The problem is that when you rotate the device then
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
方法被调用但是当你进入下一个屏幕时,这个方法不会被调用。如果您再次旋转设备,则会调用该方法。
Method gets called but when you go to the next screen then this method does not get called. if you rotate your device again then that method gets called.
因此,如果您想将下一个屏幕方向更改为设备当前方向,请使用<$检查设备的当前方向c $ c> viewDidLoad 方法或 ViewWillApper()
方法。然后根据那个设置你当前的观点。
So if you want to change next screen orientation as device current orientation, then check the device's current orientation with viewDidLoad
method or ViewWillApper()
method. Then according to that set your current view.
这篇关于如何在方向变化时管理应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!