I have static table view controller in which one cell is a container view which has another table view which dynamic. The inner table view has a text field and when on tap, the keyboard pops up. In the main (outer) table view controller, I have the below function to update the constraint on keyboard show.
func updateConstraints() {
let bottom: CGFloat = 0
if let popup = self.addItemPopupView {
self.popupBottomContraints?.isActive = false
if self.isKeyboardActive {
self.popupBottomContraints = popup.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor,
constant: -self.keyboardHeight+bottom)
} else {
self.popupBottomContraints = popup.bottomAnchor.constraint(equalTo: self.toolbar.topAnchor, constant: bottom)
}
self.popupBottomContraints?.isActive = true
}
}
But the problem is that on keyboard display, the inner table view jumps to the top inside the container view while the main view controller itself moves to the top. How to prevent the inner table view to not move at all? I have disabled scroll, bounce for the table view, but it still happens.
The outer table cell has dynamic height set to the inner table view's content height so there is no need for scroll.
I fixed this by removing the container view and using the table view directly in the main view controller.