The problem that the navigation bar moves when the keyboard pops up when using IQKeyBoardManger - personal problem

The above is a method I found online, but I have not used it successfully (maybe I don’t understand it)!

The following is the problem I encountered myself,

My chat interface is simply divided into two parts using xib, the upper UITableView (list) and the lower UITextField (input box). The main problem occurs on the iPhone X (ios11) notch mobile phone.

Problem 1: IQKeyBoardManger uses an older version, resulting in an obvious gap between the keyboard and UITextField.

Solution 1: Just upgrade IQKeyBoardManger.

Question 2: After upgrading to the latest version, when the keyboard pops up, both the UITableView and the navigation bar slide off the screen. Hiding the keyboard will also cause the navigation bar and UITextField to deviate.

Solution 2: My personal understanding of IQKeyBoardManger is that all controls must be added on the scroll view, so I first add a UIScrollView at the bottom, and then add both UITableView and UITextField on the UIScrollView, and then that's it!

My understanding may not be correct, but the effect is ok?

Guess you like

Origin blog.csdn.net/mofengluo/article/details/92081430