ios - 如果从 NavigationController 呈现 viewController,则旋转父 View Controller

标签 ios

我在我的应用程序中使用了一个 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/

相关文章:

ios - 由于 Flutter 中的模拟器错误,退回到从 NSUserDefaults 加载访问 token

ios - swift : Swipe Both UICollectionView and UIPageViewController

ios - 查询 .to 文件符号

ios - 在 SQLite 中保存 UIBezierPath

ios - 为什么我需要本地数据库 ios

ios - 对象的属性未在其他对象中显示

iphone - gzipInflate/gzipDeflate 错误

ios - 设置 map 中心和缩放以适合所有坐标

iphone - 如何使用 NSNotification

ios - SWIFT 中类似于 UIColor.systemgray 的任何标准字符串