ios - 快速将一个特定的 View Controller 设置为横向模式

标签 ios swift landscape

我们如何使用 xib 在 swift 中将一个特定的 View Controller 设置为横向模式?

func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        let orientation: UIInterfaceOrientationMask =
        [UIInterfaceOrientationMask.Portrait, UIInterfaceOrientationMask.PortraitUpsideDown]
        return orientation
}

我正在使用上面的代码,但它似乎不起作用..

最佳答案

我很确定您不能通过使用 Storyboard 来针对每个 View Controller 。如果您按原样在代码中执行此操作,则需要为该函数指定 override 关键字。您还需要确保您的应用项目支持您希望为任何特定 View Controller 支持的所有界面方向。

关于ios - 快速将一个特定的 View Controller 设置为横向模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34543912/

相关文章:

ios - Storyboard - 设置委托(delegate)

ios - Xcode Swift - 检测屏幕上颜色的触摸

ios - 如何从 subview 访问 ParentViewController 方法?

ios - 如何在 iOS 存储设置中显示下载的视频

swift - 如何同步调用CLGeocoder方法

ios - 在输入字段中输入任何文本时如何将 View 向上移动

iphone - 如何让我的 iPhone 应用程序以横向模式启动?

iphone - iOS iPad 启动横向,推送 VC,popVC, View 定位错误

swift - 向 UIAlertView 添加事件指示器

xcode - 在界面生成器中将标签旋转为横向