On the chat page, use the IQKeyboardManager navigation bar and the solution for moving up the entire page.
Problem:
When the third-party library IQKeyboardManager is used, the entire page is moved up, and the navigation bar page is removed from the display range. The preceding message is invisible on the chat interface.
Solution:
Note: Using IQKeyboardManager in the chat interface as a third-party library cannot solve this problem. At least I have not found a solution. Create a UI using ib on the internet, change the view of the Controller to scrollview, or create the UI with pure code, override the loadView method, and then set self. view = scrollview. No trial. It is too troublesome.
Solution: on the chat page, disable IQKeyBoard and monitor the keyboard to bring up notifications. Write the input box and move it up and down with the keyboard. I can see a good solution on the Internet: When the keyboard pops up, set the height of the message list tableView to (screen height-input box height-keyboard height), and move the input box up; when the keyboard disappears, the height of tableView is set to (screen height-the height of the input box), and the input box is moved down. This perfectly solves the problem of Message Display and keyboard occlusion in the chat list.
Keyboard monitoring code:
-(Void) viewDidLoad {self. listener = NO; // notification for listening to the keyboard [[NSNotificationCenter defacenter center] addObserver: self selector: @ selector (keyboardwillchangeframenoworkflow :) name: jsonobject: nil];}-(void) viewDidAppear :( BOOL) animated {[super viewDidAppear: animated]; _ updated = [[IQKeyboardManager sharedManager] isEnabled]; [[IQKeyboardManager sharedManager] setEnable: NO];}-(void) viewDidDisappear :( BOOL) animated {[super viewWillDisappear: animated]; [[IQKeyboardManager sharedManager] setEnable: _ wasKeyboardManagerEnabled];} /*** click the return button (the button at the bottom right corner of the keyboard) to call */-(BOOL) textFieldShouldReturn :( UITextField *) textField {[self sendMessage]; return YES ;} /*** call the */-(void) keyboardWillChangeFrameNotify :( NSNotification *) keyboardwillchangeframenoy {// 0 when the frame (position and size) is changed on the keyboard. the keyboard animation time CGFloat duration = [127y. userInfo [UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 1. get the final frame CGRect keyboardFrame = [policy. userInfo [UIKeyboardFrameEndUserInfoKey] CGRectValue]; // 2. the distance between the view of the computing controller and CGFloat transformY = keyboardFrame. origin. y-self. view. frame. size. height; // 3. run the animation [UIView animateWithDuration: duration animations: ^ {self. myTableView. frame = CGRectMake (0, 0, SCREENW, SCREENH + transformY-self. inputView. height); self. tableViewBottomConstraint. constant =-transformY + 44; // The distance between the bottom of tableView and the bottom of the parent view is self. inputView. transform = CGAffineTransformMakeTranslation (0, transformY); [self scrollTableViewToBottom];}] ;}/ *** tableView quickly scrolls to the bottom */-(void) scrollTableViewToBottom {if (self. messageFrames. count) {NSIndexPath * indexPath = [NSIndexPath indexPathForRow :( self. messageFrames. count-1) inSection: 0]; [self. myTableView scrollToRowAtIndexPath: indexPath atScrollPosition: UITableViewScrollPositionBottom animated: YES] ;}- (void) dealloc {[[nsicationicationcenter defacenter center] removeObserver: self];}