UITableViewScrollPositionNone does not view table view

When using selectRowAtIndexPath:animated:scrollPosition: I pass UITableViewScrollPositionNone . Despite this name, I expect the tableview to scroll if necessary so that the row is visible (and does not scroll if it is already visible).

UITableViewScrollPositionNone - The table view scans the row of interest to be fully visible with minimal movement. If the line is already fully visible, scrolling does not occur. For example, if the line is above the visible area, the behavior is identical to the behavior specified in UITableViewScrollPositionTop. This is the default value.

However, I found that the table view does not scroll at all. If I use UITableViewScrollPositionTop or UITableViewScrollPositionBottom , the table view scrolls as expected.

Is it possible that the documentation for this is incorrect? Or am I missing something?

+6
source share
2 answers

The documentation for UITableView selectRowAtIndexPath: animated: scrollPosition: contains a section describing what you are experiencing.

Special considerations related to UITableViewScrollPositionNone will not result in scrolling, but not in the minimum scrolling for this constant. To scroll the selected row to a minimum scroll, select a row using this method using UITableViewScrollPositionNone, then call scrollToRowAtIndexPath: atScrollPosition: animated: with UITableViewScrollPositionNone.

Hope this helps!

+4
source

You need to make sure that there is a space in the view of the contents of the table view for scrolling. I need to scroll the table view, because the user clicks on the text field and keyboard, I need to expand the contents of the table view to the height of the keyboard so that I can view the list of tables. Like this:

 UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, keyboardFrame.size.height, 0.0); self.tableView.contentInset = contentInsets; self.tableView.scrollIndicatorInsets = contentInsets; [self.tableView scrollToRowAtIndexPath:self.currentEditingCellIndexPath atScrollPosition:UITableViewScrollPositionNone animated:YES]; 
0
source

All Articles