Open M0rtyMerr opened 5 years ago
A simple instance of UIScrollView with UITextField in contentView. I can attach a sample project if it's needed.
RxKeyboard.instance.visibleHeight .debug("RxKeyboard") .drive(onNext: { [scrollView] in scrollView?.contentInset.bottom = $0 }) .disposed(by: disposeBag) scrollView.rx.observe(UIEdgeInsets.self, "contentInset") .debug("ScrollView") .subscribe() .disposed(by: disposeBag)
After assigning zero (keyboard hides) it reverts back to previous value. Output:
2019-07-16 13:16:14.546: RxKeyboard -> Event next(0.0) 2019-07-16 13:16:14.547: ScrollView -> Event next(Optional(__C.UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0))) 2019-07-16 13:16:14.548: ScrollView -> Event next(Optional(__C.UIEdgeInsets(top: 0.0, left: 0.0, bottom: 315.0, right: 0.0)))
Maybe, it's not RxKeyboard problem, however implementing it with raw NotificationCenter resolves the issue. Changing RxKeyboardsubscription code to async (code smell) also resolves the issue:
RxKeyboard
NotificationCenter
RxKeyboard.instance.visibleHeight .asObservable() .observeOn(MainScheduler.asyncInstance) .bind { [scrollView] in scrollView?.contentInset.bottom = $0 } .disposed(by: disposeBag)
Maybe I just don't understand something. Could u please share your thoughts?
A simple instance of UIScrollView with UITextField in contentView. I can attach a sample project if it's needed.
After assigning zero (keyboard hides) it reverts back to previous value. Output:
Maybe, it's not
RxKeyboard
problem, however implementing it with rawNotificationCenter
resolves the issue. ChangingRxKeyboard
subscription code to async (code smell) also resolves the issue:Maybe I just don't understand something. Could u please share your thoughts?