有没有办法以shouldChangeTextIn UITextViewRxSwift 的方式实现 的委托方法?我的目标是限制用户的文本输入。我只有这个:
self.textView.rx.text
.orEmpty
.scan("") { (previous, new) -> String in
return new.count > 254 ? previous : new
}
.bind(to: self.viewModel.notes)
.disposed(by: self.disposeBag)
这是用于数据的,但我不知道如何防止 254 计数后的进一步输入。
我也找到RxTextViewDelegateProxy了,但我也不确定如何使用它。
let rxTVDelegateProxy = RxTextViewDelegateProxy(textView: self.textView)