ios - 键盘在 Web View 中未正确显示 - 横向模式

标签 ios swift webview landscape

我正在展示这样的自定义 WebView 。

let vc = CustomWebViewVC.viewController()
    vc.delegate = self
    present(vc, animated: true, completion: nil)

我已经实现了它以在横向模式下显示自定义 WebView 。

override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
    return .landscapeRight
}

//----------------------------------------------------------

override var shouldAutorotate: Bool {
    return false
}

问题

CustomWebViewVC 在横向模式下正确打开,但是当我点击 webivew 内的文本字段时会发生这种情况。

enter image description here

我不知道是什么问题。

有什么建议吗?

最佳答案

缺少的方法是这个

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.landscapeRight
}

在 View Controller 中添加这个之后就成功了。

要在横向模式下打开 viewcontroller,您需要像我一样实现所有三个方法。

override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
    return .landscapeRight
}

//----------------------------------------------------------

override var shouldAutorotate: Bool {
  return false
}

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.landscapeRight
}

关于ios - 键盘在 Web View 中未正确显示 - 横向模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55038297/

相关文章:

iphone - 创建阴影 View

ios - 如何以编程方式在 Swift 3 上复制 UILabel 样式

javascript - 如何从在 Android Webview 中运行的网站注销?

ios - UITableViewController 中的顶部栏背景

android - 使用离线 map 进行应用程序开发

ios - 如何获取 UITableViewCell 内标签的高度?

ios - 快速更新了每个 API 的 almofire timeoutIntervalForRequest 吗?

ios - 如何在 iOS 中的折线图(图表)的标签中显示文本

cocoa - 禁用与 Cocoa WebView 的所有交互

android - 需要帮助了解 webview android 的页面源