[英]Swift 2.1 - Inputing information into a TextView which populates a Textfield at the same time?
I am currently using a framework called "Swift Validator", it only allows for textfields to be used. 我目前正在使用一个名为“ Swift Validator”的框架,它仅允许使用文本字段。 In my case I need a textView, my question is how do I input information that I type into the textview which then populates a textfield in the background at the same time?
在我的情况下,我需要一个textView,我的问题是如何输入要输入的信息到textview中,然后同时在后台填充一个textfield? as well as when removing inputed text?
以及删除输入的文字时?
Use the UITextViewDelegate
method textViewDidChange
to listen for changes to the Text View. 使用
UITextViewDelegate
方法textViewDidChange
侦听对Text View的更改。 When the method is called, update the Text Field. 调用该方法时,更新文本字段。 Here's an example:
这是一个例子:
func textViewDidChange(theTextView: UITextView) {
self.textField.text = theTextView.text
}
Don't forget to extend UITextViewDelegate
and to set the Text View's delegate to self
. 不要忘记扩展
UITextViewDelegate
并将Text View的委托设置为self
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.