Disabling automatic scrolling of UITableView when editing UITextField inside UITableViewCell

后端 未结 9 909
别跟我提以往
别跟我提以往 2020-11-30 00:40

I\'m using custom UITableViewCells inside my UITableView. Each of these UITableViewCells is pretty high and contains a UITextFie

9条回答
  •  难免孤独
    2020-11-30 00:50

    Unfortunately, overriding -viewWillAppear: doesn't work for me in iOS 8.

    Here is my solution (as in UITableViewController implementation):

    - (void)viewDidLoad {
    
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self.tableView name:UIKeyboardWillShowNotification object:nil];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self.tableView name:UIKeyboardWillHideNotification object:nil];
    }
    

    Since the auto-scrolling behaviour is invoked by UIKeyboard's show/hide notifications, so just NOT observe them.

提交回复
热议问题