开发者

iPhone - scroll UITableView to index

开发者 https://www.devze.com 2022-12-17 17:49 出处:网络
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:

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:.

0

精彩评论

暂无评论...
验证码 换一张
取 消