带有大屏幕的iPhones (Plus/Max系列)有这样一个功能,当您将设备旋转到横向模式时,UI将变得与iPads上的一样-您的主屏幕在左侧,详细信息在右侧。有没有办法仅在iPhones上禁用此功能?我的意思是,如果我将我的iPhone设置为横向模式,那么UI将保持不变(拆分视图控制器不会扩展)。我试着使用splitViewController?.preferredDisplayMode = .primaryHidden,但在这种情况下,detailed控制器没有后退按钮,你基本上被卡住了,因为你不能后退。谢谢
发布于 2020-07-01 23:40:07
尝试重写overrideTraitCollection(forChild:)方法:
override func overrideTraitCollection(forChild childViewController: UIViewController) -> UITraitCollection? {
if UIDevice.current.userInterfaceIdiom != .pad {
return UITraitCollection(horizontalSizeClass: .compact)
} else {
return super.traitCollection
}
}https://stackoverflow.com/questions/62680207
复制相似问题