searchBar.rx.textDidBeginEditing
.subscribe { [unowned self] in
print("im begining diting")
self.searchBar.setShowsCancelButton(true, animated: true)
}
.disposed(by: disposeBag)
它不起作用,也许我的方法错误?但是我有方法
searchBar.rx.text
.asObservable()
.bind(to: directoryViewModel.searchTextObservable)
.disposed(by: disposeBag)
它正常工作
答案 0 :(得分:-1)
我忘了穿上下一步:
searchBar.rx.textDidBeginEditing
.subscribe(onNext: { [unowned self] in
self.searchBar.setShowsCancelButton(true, animated: true)
}).disposed(by: disposeBag)