RxSwift textFiled和textView
1.测试代码
override func viewDidLoad() {
super.viewDidLoad()
// 1: textFiled & textView来了
// 2: why 来两次
textFiled.rx.text.subscribe(onNext: { (text) in
print("输入来了 \(text)")
})
textView.rx.text.subscribe(onNext: { (text) in
print("textView:输入来了 \(text)")
})
// event
textFiled.addTarget(self, action: #selector(textFiledChange), for: .allEditingEvents)
}
@objc func textFiledChange() {
print("laile")
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
textFiled.text = "LiHua"
//textFiled.sendActions(for: .allEditingEvents)
textView.text = "LiMing"
}
- 当我执行
textFiled.text = "LiHua"
textView.te