[英]mvvmcross ios lock portrait orientation for specific MvxViewController
[英]iOS lock specific ViewController to specific orientation
我想在特定的ViewController中将设备的方向锁定为仅纵向,但没有可用的解决方案在起作用。 它嵌入在UINavigationController中。
我将其部署到iOS7,并在常规设置中同时检查了横向和纵向,因为我希望它可以针对特定的VC以外的其他VC进行旋转。
extension UINavigationController {
public override func shouldAutorotate() -> Bool {
return visibleViewController.shouldAutorotate()
}
public override func supportedInterfaceOrientations() -> Int {
return visibleViewController.supportedInterfaceOrientations()
}
}
这部分代码在我的ViewController类中
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientation.Portrait.rawValue)
}
“不推荐使用iOS 8中所有与旋转有关的方法”(请参阅UIViewController上的文档)。 这可能就是为什么它不适合您的原因。
我认为Apple这样做是为了在整个应用程序中保持用户体验的一致性。
我发现了问题,因为我正在使用SWRevealViewController,因此父VC会覆盖子视图的旋转设置。
因此,我只是将其子类化,并按预期调整自动旋转和方向设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.