0

As we know, click the UITableView when it is scrolling will stop it from scrolling, there is a text field on the top of the table view, and now I want to execute the click method when the text field begin editing in order to stop the table view from scrolling, How can I achieve this? How to execute the click method when the table view is scrolling. Thanks for every answer.

- (void)textFiledTextDidBegin:(UITextField *)textField {
    //stop the tableview from scrolling
}
bugfreerammohan
  • 1,471
  • 1
  • 7
  • 22
RateRebriduo
  • 265
  • 3
  • 11
  • see this for help: https://stackoverflow.com/questions/9637089/disabling-automatic-scrolling-of-uitableview-when-editing-uitextfield-inside-uit – Anbu.Karthik Mar 25 '19 at 06:13
  • I want to get the click method(click the UITableView when it is scrolling will stop it from scrolling) and execute the method when the UITextField begin editing, and my UITextField is on the top of UITableView so that I don't have the problem of can't see the UITextField. – RateRebriduo Mar 25 '19 at 06:23

2 Answers2

1

You can stop the scroll by force set the contentOffset

- (void)textFiledTextDidBegin:(UITextField *)textField {
    [your_tableView setContentOffset:your_tableView.contentOffset animated:NO];
}
Quoc Nguyen
  • 2,839
  • 6
  • 23
  • 28
0

Swift 5:

I have this same question. This seems to have worked for me.

func textFieldDidBeginEditing(_ textField: UITextField) {
        UIOffset.zero
    }
StonedStudio
  • 507
  • 3
  • 20