gpt4 book ai didi

ios - 强制 UIWebView 的横向方向?

转载 作者:行者123 更新时间:2023-11-28 13:05:49 25 4
gpt4 key购买 nike

我有一个应用程序,其中所有 View 都是纵向 View ,但只有一个 View 是加载 PDF 的 UIWebView 需要横向。

我的项目设置如下:

enter image description here

我尝试了以下方法:

 override func shouldAutorotate() -> Bool {
return false
}

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
let orientation: UIInterfaceOrientationMask = [UIInterfaceOrientationMask.Landscape, UIInterfaceOrientationMask.LandscapeLeft]
return orientation
}

上面的代码似乎不起作用。我通过在线搜索获得了代码。我不确定我做错了什么。任何建议都会有所帮助,如果您能提供一些示例代码,那就太好了。

我只想为一个 UIWebView 强制横向。

编辑:

enter image description here

错误:

enter image description here

如果这里难以阅读是错误的:

支持的方向与应用程序没有共同的方向,[KM_T_World.MainViewController shouldAutorotate] 返回 YES'

最佳答案

在你的 View Controller 中实现这个:

override func viewDidLoad() {
super.viewDidLoad()
UIViewController.attemptRotationToDeviceOrientation()
}

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return [UIInterfaceOrientationMask.LandscapeLeft, UIInterfaceOrientationMask.LandscapeRight]
}

settings info

关于ios - 强制 UIWebView 的横向方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32841403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com