ios - UIViewController 在纵向模式下空白,但 subview 在横向模式下可见?

标签 ios swift uiviewcontroller uiinterfaceorientation

一件很奇怪的事情发生了。我在 IB 中创建了一个 UIViewController 并使用了

detailController = self.storyboard?.instantiateViewControllerWithIdentifier("detailView")
self.navigationController?.pushViewController(detailController!, animated: true)

显示 View 。但奇怪的是,它在纵向模式下呈现空白屏幕,而在横向模式下呈现正确的 View ,如屏幕截图所示

我试过了

self.presentViewController(traceInfoController!, animated: true, completion: nil)

也没有帮助。

我的代码库比较大,我已经把方向适配的代码都注释掉了。

知道这样的事情是如何发生的以及如何纠正它吗?

enter image description here

enter image description here

最佳答案

谢谢大家!我刚刚弄明白了!

我不记得我什么时候在 IB 中将布局模式更改为 (wAny hCompact)!

enter image description here

请看最后一行的小文字,上面写着 iPhone in landscape!这就是针对不同屏幕尺寸设计不同布局的方法!

要解决这个问题,只需更改为 (wAny hAny) 然后编辑即可。

关于ios - UIViewController 在纵向模式下空白,但 subview 在横向模式下可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33215273/

相关文章:

ios - 如何控制 UIViewController 的 View 框架

ios - 添加后不显示启动画面

ios - UIView AnimateWithDuration 处理速度很快

ios - 如何快速打开文件并在其中附加字符串

ios - Swift:使用未解析的标识符 'present'

ios - touchesBegan 不调用容器 View Controller

ios - 三角形与 Quartz 2D 绘图完美对齐

ios - 用于数据验证的 Swift VIPER Interactor 和 Presenter 规则

ios - Xcode 6.3.1、Swift、iOS 8 Interface Builder - 横向时卸载按钮

ios - 自定义警报 View 的验证