When I implement UITextFieldDelegate
through RxSwift, I do this:
self.textField_AddressType.rx.controlEvent(.editingDidBegin).subscribe { _ in
// Code here...
}.disposed(by: self.disposeBag)
But when I apply it to UITextView
,
self.textView.rx.controlEvent(.editingDidBegin).subscribe { _ in
// Code here...
}.disposed(by: self.disposeBag)
I get an error:
'UITextView' is not a subtype of 'UIControl'
I couldn't find anything about this issue, is there another way to implement UITextViewDelegate
in RxSwift?
textView.rx.didBeginEditing.subscribe(onNext: { n in
value = n
}, onCompleted: {
completed = true
})
You can try this.
You can map event and create Observable string like this
self.tfUserName.rx.controlEvent(UIControlEvents.editingDidEnd)
.map { self.tfUserName.text }
.filter { $0 != nil }
.map { $0! }
.subscribe(onNext: { (text) in
// Code here...
}).disposed(by: self.disposeBag)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With