在触发 UIControlEvent Editing Changed 后,我想使用 RxSwift 从 UITextField 获取文本。
为了做到这一点:
我像这样将故事板的文本字段出口连接到我的视图控制器。
@IBOutlet weak var currentPasswordTextField: UITextField!
然后在这个文本字段的 didSet 属性上,我尝试了这个:
@IBOutlet weak var currentPasswordTextField: UITextField!{
didSet{
currentPasswordTextField
.rx
.controlEvent(.editingChanged)
.asObservable()
.subscribe(onNext: { (text) in
//I want here to print the text after the editing changed.
print(text)
})
.disposed(by: disposeBag)
}
}
但文本是无效的而不是字符串..
如果有人可以帮助我不胜感激。提前致谢。
PS我不想使用IBActions。