iOS dynamically load new cell to the bottom of a t

2019-08-08 17:56发布

I'm working on an iOS project where I want to dynamically add more cell to the bottom of the tableview once the user reaches the bottom. I currently have this working by calling a method that fetches more data that is added to the array that I'm using to hold my cells. When I'm done adding the objects to the array I call [tableView reloadData]. This works, but it doesn't visually load the cell until the tableview stops scrolling.

I also tried using [tableView insertRowsAtIndexPaths: inSection:withRowAnimation: UITableViewRowAnimationNone]. But I was getting very strange behavior where random cell would disappear and not show back up until I scrolled that section of the tableView off screen and then back to that area.

Is there a way to get the tableView to reload even if the tableView is still in mid scroll when the [tableView reloadDate] is called?

Thank you!

1条回答
女痞
2楼-- · 2019-08-08 18:13

Check out: How to know when UITableView did scroll to bottom in iPhone neoneye's answer about - (void)scrollViewDidScroll:(UIScrollView *)aScrollView { was exactly what I was looking for. I moved the method call to fetch more cell right after the NSLog(@"load more rows");

Thank you JiaYow for steering me in the right direction!

查看更多
登录 后发表回答