Friends and who came across - I try to implement the TableView offset up when the keyboard appears. After the offset, the scroll disappears and the TableView cannot be scrolled. What is the problem?

-(void) keybordWillShow: (NSNotification *) notification { NSDictionary *keyboardPosition = notification.userInfo; NSValue *keyboardFrameTMP = [keyboardPosition objectForKey:UIKeyboardFrameEndUserInfoKey]; CGRect keyboardFrame = [keyboardFrameTMP CGRectValue]; NSInteger tableViewOffset =keyboardFrame.size.height; [UIView animateWithDuration:0.25f animations:^{ _myTableView.contentInset = UIEdgeInsetsMake(-tableViewOffset, 0, 0, 0); }];} 

scrollEnabled = YES does not help

  • strange code you have, you put strange inset, UIEdgeInsetsMake (-tableViewOffset, 0, 0, 0). Check out this library here: github.com/kirpichenko/EKKeyboardAvoiding . There is not very complicated processing code. - Andrew Romanov
  • I agree with @AndrewRomanov, the problem is clearly in _myTableView.contentInset - Vitali Eller
  • normal inset there, in vain you confuse a person - everything as recommended by developer.apple.com/library/ios/documentation/StringsTextFonts/… - Max Mikheyenko
  • ATP, otherwise I am already under-upset - MxTM
  • for the dynamic option with scrollIndicatorInsets helps - everything is displayed. static did not work. We understand ... - MxTM

1 answer 1

_myTableView.contentInset = UIEdgeInsetsMake (-tableViewOffset, 0, 0, 0);

In this line, you shift the table view content upward by a tableViewOffset value, which is equal to the keyboard height by code. Accordingly, the area that reacts to the scroll is shifted.

I would suggest you not to work in this vein. Use NSLayoutConstraint and change the value of a particular construct when the keyboard appears.