如何在横向模式下设置某些视图控制器,默认情况下在纵向设置其他视图

时间:2023-01-19 21:01:46

How to set some view controller in landscape mode and some other in portrait by default.No need to rotate.I need it as landscape only or portrait only.

如何在横向模式下设置一些视图控制器,在默认情况下设置其他一些视图控制器。不需要旋转。我只需要它作为风景或仅限肖像。

override func shouldAutorotate() -> Bool {

    return false

}



override func supportedInterfaceOrientations() -> Int {

    return Int(UIInterfaceOrientationMask.Landscape.rawValue)

}

For portrait

对于肖像

    override func supportedInterfaceOrientations() -> Int {

    return Int(UIInterfaceOrientationMask.Portrait.rawValue)

}

It cannot work porperly

它无法正常工作

Am using xcode 6.4. ios 8

我正在使用xcode 6.4。 ios 8

Thanks in Advance

提前致谢

2 个解决方案

#1


0  

Add this to your AppDelegate:

将其添加到AppDelegate:

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.All
}

Asks the delegate for the interface orientations to use for the view controllers in the specified window

向代表询问用于指定窗口中的视图控制器的接口方向

#2


0  

Go to your Main.Storyboard then go to your attribute inspector and change the device orientation to the orientation you want. You can uncheck if user can change orientation or not.

转到Main.Storyboard,然后转到属性检查器,将设备方向更改为所需的方向。您可以取消选中用户是否可以更改方向。

#1


0  

Add this to your AppDelegate:

将其添加到AppDelegate:

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.All
}

Asks the delegate for the interface orientations to use for the view controllers in the specified window

向代表询问用于指定窗口中的视图控制器的接口方向

#2


0  

Go to your Main.Storyboard then go to your attribute inspector and change the device orientation to the orientation you want. You can uncheck if user can change orientation or not.

转到Main.Storyboard,然后转到属性检查器,将设备方向更改为所需的方向。您可以取消选中用户是否可以更改方向。