Hi, when I subscribe to UITextField like this, when user press "done" button, keyboard is dismissed. It's not what I want, because in my case I want to clear textfield and allow user input another text into it.
// because of that code, keyboard dismiss :(
textField.rx.controlEvent(UIControlEvents.editingDidEndOnExit)
.subscribe(onNext: { [weak self] _ in
guard let text = textField.text, text.isNotEmpty else { return }
// do sth
textField.text = nil
})
.addDisposableTo(self.bag)
how to handle button and keep first responder on the same uitextfield?
Hi @adamsmaka ,
This is a UIKit question and not Rx question, sorry.
Try searching for becomeFirstResponder or some other way.
Any ideas how to handle Done/Return/Search button of UITextField with RxCocoa?
Hi @kzaher I believe this is actually a problem specific with RxSwift and this issue should be reopened.
The standard behavior with UIKit is the keyboard does not hide when the user selects the Return Key, this is functionality that needs to be specified. However when utilising textField.rx it now automatically hides. This is not expected behavior or behavior in line with UIKit.
@bnussey If you believe that this is a RxSwift bug and that we are doing something wrong, feel free to make a PR.
Most helpful comment
Any ideas how to handle Done/Return/Search button of UITextField with RxCocoa?