RxSwiftCommunity / RxKeyboard

Reactive Keyboard in iOS
MIT License
1.61k stars 175 forks source link

How to use for texfields in tableview #29

Closed kmuddapu closed 6 years ago

kmuddapu commented 7 years ago

I have textfields in 3 sections in tableview . how to show keyboard near to textfield ?

Im using below code but when I click on bottom textfield . View going to top almost near to navigation.

RxKeyboard.instance.visibleHeight
            .drive(onNext: { keyboardVisibleHeight in
                self.view.setNeedsLayout()
                UIView.animate(withDuration: 0) {
                    self.myTableView.contentInset.bottom = keyboardVisibleHeight
                    self.myTableView.scrollIndicatorInsets.bottom  = self.myTableView.contentInset.bottom                    
                    self.view.layoutIfNeeded()
                }
            })
            .disposed(by: disposeBag)
devxoul commented 7 years ago

You should also adjust tableView's contentOffset.

kmuddapu commented 7 years ago

@devxoul Can you please provide me any sample code.

I wrote below code but not working . Tableview not scrolling to row selected.

RxKeyboard.instance.willShowVisibleHeight .drive(onNext: { keyboardVisibleHeight in self. myTableView.contentOffset.y += keyboardVisibleHeight }) .disposed(by: disposeBag)

devxoul commented 7 years ago

@kmuddapu try using scrollToRowAtIndexPath instead.