我有一个
稍后,我将
如果我在横屏模式下启动应用程序,但ControllerA未处理此模式,然后移至ControllerB,则我的内容(+状态栏)仍为纵向。如果此时手动旋转设备,则会获得正确的内容布局。
如何使ControllerB以设备方向呈现自身?
以下是我从ControllerA和ControllerB的viewWillAppear方法中看到的内容:
UINavigationController
作为我的UIWindow的rootViewController,然后向UINavigationController
添加了一个仅支持 Portrait 方向的UIViewController
(ControllerA
) 作为其rootViewController
。稍后,我将
UINavigationController
的rootViewController
替换为一个新的UIViewController (ControllerB
)。ControllerB同时支持 Portrait 和 Landscape 两种方向。我希望我的初始屏幕(ControllerA
)只能在Portrait中使用,而应用程序的其余部分可以支持Portrait和Landscape两种方向。[self.navigationController setViewControllers:@[viewControllerB] animated:NO];
| UINavigationController launches:
| ----ControllerA (rootViewController): Portrait only
| ----ControllerB (rootViewController): Portrait and Landscape supported
如果我在横屏模式下启动应用程序,但ControllerA未处理此模式,然后移至ControllerB,则我的内容(+状态栏)仍为纵向。如果此时手动旋转设备,则会获得正确的内容布局。
如何使ControllerB以设备方向呈现自身?
以下是我从ControllerA和ControllerB的viewWillAppear方法中看到的内容:
navigationController orientation: UIInterfaceOrientationPortrait
UIViewController interfaceOrientation: UIInterfaceOrientationPortrait
<!-----------!!two values are different!!------------------>
[[UIDevice currentDevice] orientation]: UIDeviceOrientationLandscapeLeft
[[UIApplication sharedApplication] statusBarOrientation]: UIInterfaceOrientationPortrait
Phone is physically held in Landscape at this point in time.