我使用另一个文本编辑器在 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.
}
最佳答案
尝试使用 UIView
父类(super class)(UIWebView
的父类(super class)以及 UITextField
的超父类(super class))属性 .userInteractionEnabled
:
myWebViewTextField.userInteractionEnabled = false
或者,如果这不是您要查找的内容,请尝试 UITextField
的父类(super class) UIControl
中的属性 .enabled
:
myWebViewTextField.enabled = false
UIView.userInteractionEnabled
PropertyA Boolean value that determines whether user events are ignored and removed from the event queue.
来自Language Reference for UIVIew
.
UIControl.enabled
PropertyA Boolean value that determines whether the receiver is enabled.
关于swift - 快速禁用 UIwebView textField 中的键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34571440/