iPhone - scroll UITableView to index
Once my UITableView h开发者_StackOverflowas been populated with data, I want to scroll to a specific index. I think this is how you do it:
[[self tableView] scrollToRowAtIndexPath:[NSIndexPath indexPathWithIndex:3] atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
The problem is when I'm supposed to run this. How do you know when a table has finished loading data?
First of all, you should use indexPathForRow:inSection:
for index paths in table views.
If you want to do something after the table view is loaded, use your view controller's viewDidAppear:
, and if this is too early, enqueue a selector using performSelector:withObject:afterDelay:
.
精彩评论