Question about Apple's LazyTableImages sample - Doesn't behave exactly like the app store

后端 未结 2 1679
天命终不由人
天命终不由人 2020-12-24 04:05

I have a UITableView with a list of items, each having it\'s own image. I thought Apple\'s LazyTableImages sample project would be perfect to learn from, and use to impleme

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 04:42

    Check out UIScrollViewDelegate. I've implemented something like this by listening for scrollViewDidScroll:, calculating the scroll speed (by checking the contentOffset against the last recorded contentOffset, divided by the difference in time), and starting to load images once the speed drops below a certain threshold. (You could achieve something similar with UIScrollViewDelegate's scrollViewDidEndDragging:willDecelerate: as well).

    Of course, you don't have to check the speed; you could just load images on UITableViewDelegate's tableView:willDisplayCell:forRowAtIndexPath: whenever you see a new cell, but I've found that if the user is flipping through tons of cells, you don't need to bother until you see that they're going to slow down to browse.

提交回复
热议问题