我尝试编辑文本时,searchBar.rx.textDidBeginEditing不起作用

时间:2018-11-17 15:13:11

标签: ios swift rx-swift rx-cocoa

    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)

它正常工作

1 个答案:

答案 0 :(得分:-1)

我忘了穿上下一步:

searchBar.rx.textDidBeginEditing
.subscribe(onNext: { [unowned self] in

    self.searchBar.setShowsCancelButton(true, animated: true)

}).disposed(by: disposeBag)