ios - unrecognized selector for UITapGestureRecognizer in RxSwift -


im new in rxswift , want use uitapgesturerecognizer dismiss keyboard:

  let tapgest = uitapgesturerecognizer()     tapgest.rx.event.subscribe(onnext: {[weak self] _ in         self?.view.endediting(true)     }).disposed(by: disposebag)     view.addgesturerecognizer(tapgest) 

but when use gesture, app terminating error :

*** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[ttgc7rxcocoa13gesturetargetcso22uitapgesturerecognizer eventhandler:]: unrecognized selector sent instance 0x600000446bd0'

there helper methods put tap gestures onto views in rxcocoa. there, want filter gesture recognizer's state don't pick events don't matter. like:

view.rx.tapgesture()     .filter { $0.state == .ended }     .subscribe(onnext: { _ in         //     })     .disposed(by: disposebag) 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -