Ams*_*eer 12 iphone screen-orientation ios swift
我正在创建一个仅支持纵向模式的应用程序.我不希望风景或人像颠倒.我尝试了一些代码.这允许我锁定纵向模式.
我正在使用navigationcontroller和presentviewcontroller.现在我的问题是:1.如果我将设备颠倒并打开我的应用程序,它会以颠倒模式打开,这是错误的.2.我点击一些按钮,进入presentviewcontroller,返回纵向模式.
我希望所有的navigationcontroller和presentviewcontroller都处于纵向模式
我的代码:
我设置了设备orientarion肖像 Target -> General -> Deployment Info -> Portrait
在我的appdelagate.swift中:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.Portrait
}
Run Code Online (Sandbox Code Playgroud)
在我的第一个视图控制器.这基本上是导航控制器的孩子
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return [UIInterfaceOrientationMask.Portrait ]
}
Run Code Online (Sandbox Code Playgroud)
编辑1:
我也定了 StoryBoard -> ViewController -> Attribute Inspector -> Orientation -> Portrait
编辑2:
tec*_*erd 31
转到目标 - >常规并将方向模式设置为纵向.
另请查看info.plist.确保Supported Interface Orientations只包含一个值(纵向).有时它从设置中删除但未在plist文件中更新.
| 归档时间: |
|
| 查看次数: |
18332 次 |
| 最近记录: |