Ios 在通用应用程序中禁用iPhone拆分视图控制器的横向
我有一个带有Ios 在通用应用程序中禁用iPhone拆分视图控制器的横向,ios,objective-c,iphone,swift,ipad,Ios,Objective C,Iphone,Swift,Ipad,我有一个带有UISplitViewController的通用应用程序。我希望iPad版本可以在纵向和横向两种模式下工作,但我只希望该应用程序在iPhone上可以在纵向模式下工作。我尝试在我的主视图控制器上使用以下命令,但无效: override func shouldAutorotate() -> Bool { return false } override func supportedInterfaceOrientations() -> UIInterfaceOrient
UISplitViewController
的通用应用程序。我希望iPad版本可以在纵向和横向两种模式下工作,但我只希望该应用程序在iPhone上可以在纵向模式下工作。我尝试在我的主视图控制器上使用以下命令,但无效:
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.Portrait
}
我认为问题在于分割视图控制器覆盖了这两种方法。有什么想法吗?我想这就是你想要的
[splitViewController setHidesMasterViewInPortrait:NO];
我通过在
AppDelegate
中设置启动时支持的应用程序界面方向,设法解决了这个问题:
let deviceIdiom = UIScreen.mainScreen().traitCollection.userInterfaceIdiom
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
if deviceIdiom == .Pad {
return UIInterfaceOrientationMask.All
}
return UIInterfaceOrientationMask.Portrait
}
我想一起禁用景观,虽然我在UISplitViewController上再也看不到这个属性了。