Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewScrollPositionNone does not scroll the table view

When using selectRowAtIndexPath:animated:scrollPosition:, I am passing in UITableViewScrollPositionNone. Despite the name, I am expecting the tableview to scroll when necessary so that the row is visible (and not scroll if it is already visible).

UITableViewScrollPositionNone - The table view scrolls the row of interest to be fully visible with a minimum of movement. If the row is already fully visible, no scrolling occurs. For example, if the row is above the visible area, the behavior is identical to that specified by UITableViewScrollPositionTop. This is the default.

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

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

like image 254
Ben Packard Avatar asked Jan 08 '13 20:01

Ben Packard


1 Answers

The documentation for UITableView's selectRowAtIndexPath:animated:scrollPosition: has a section that describes what you are experiencing.

Special Considerations Passing UITableViewScrollPositionNone will result in no scrolling, rather than the minimum scrolling described for that constant. To scroll to the newly selected row with minimum scrolling, select the row using this method with UITableViewScrollPositionNone, then call scrollToRowAtIndexPath:atScrollPosition:animated: with UITableViewScrollPositionNone.

Hope that helps!

like image 59
dfujiwara Avatar answered Oct 24 '22 12:10

dfujiwara