我在我的应用程序中使用了一个 NavigationController
,并且从那里,我呈现了一个像弹出窗口一样的 viewController
。因此,如果我旋转设备,我可以旋转 topView(Presented viewController
) 但无法旋转位于导航 Controller 顶部的父 View Controller 。
我需要关于为什么会发生这种情况以及如何解决的指导。
最佳答案
如果您的父 View Controller (Presenting view controller)不是可见 View Controller ,则永远不会在父 View Controller 中调用旋转方法(- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
)(呈现 View Controller )。所以你应该根据状态栏的方向明确地旋转你的 View Controller 。但是,当您关闭呈现的 View Controller 时,viewWillLayoutSubviews 方法将在您的父 View Controller 中调用。在那里做事...
在你的父 View Controller 中:
- (void)viewWillLayoutSubviews
{
//Check your your view controller is visible. If not visible then call
[self willRotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation] duration:0];
}
关于ios - 如果从 NavigationController 呈现 viewController,则旋转父 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24378607/