swift - 快速禁用 UIwebView textField 中的键盘

标签 swift uiwebview

我使用另一个文本编辑器在 html/css/js 中编写了一个 webApp,然后将文本复制到现有 Xcode 项目中的相关文件中。

该项目在 webView 内运行“左图”,但是当我在文本字段“右图”内单击时,库存键盘的一部分覆盖了 2 个底部按钮。

我希望看到一个功能齐全的键盘,但我真的很想将其全部禁用,因为稍后我会提供自己的键盘。

在这种情况下,如何在点击 webView textField 时禁用标准键盘?

Swift 2.1 和 Xcode 7.2。

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var mainWV: UIWebView!
override func viewDidLoad() {
    super.viewDidLoad()

    //load a file
    let localfilePath = NSBundle.mainBundle().URLForResource("index", withExtension: "html");
    let myRequest = NSURLRequest(URL: localfilePath!);
    mainWV.loadRequest(myRequest);

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

enter image description here

最佳答案

尝试使用 UIView 父类(super class)(UIWebView 的父类(super class)以及 UITextField 的超父类(super class))属性 .userInteractionEnabled:

myWebViewTextField.userInteractionEnabled = false

或者,如果这不是您要查找的内容,请尝试 UITextField 的父类(super class) UIControl 中的属性 .enabled:

myWebViewTextField.enabled = false

UIView.userInteractionEnabled Property

A Boolean value that determines whether user events are ignored and removed from the event queue.

来自Language Reference for UIVIew .

UIControl.enabled Property

A Boolean value that determines whether the receiver is enabled.

来自Language Reference for UIControl .

关于swift - 快速禁用 UIwebView textField 中的键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34571440/

相关文章:

objective-c - 在显示 UIWebView 的父 ViewController 之前渲染它

html - 从 UIWebView 读取 HTML 内容

swift - 创建自定义 UITextfield

Javascript分割html内容

ios - Swift - QR 扫描仪抛出 nil 错误

ios - 根据屏幕大小更改节点定位 Swift/Sprite Kit

ios - 在 UIScrollView 内滚动时,调整大小的 UIWebView 返回到原始大小

iphone - Xcode 4.3 从 UIWebView 中的按钮在 safari 中打开相同的 url

swift - 如何在自定义 UIView 中隐藏键盘?

ios - 为什么图像这么小?