Optimized Image Loading in a UIScrollView

前端 未结 5 1725
离开以前
离开以前 2020-12-22 18:19

I have a UIScrollView that has a set of images loaded side-by-side inside it. You can see an example of my app here: http://www.42restaurants.com. My problem comes in with m

5条回答
  •  一整个雨季
    2020-12-22 19:14

    One option, although less visually pleasing, is to only load images when the scrolling stops.

    Set a flag to disable image loading in:

    -scrollViewWillBeginDragging:
    

    Re-enable loading images when the scrolling stops using the:

    -scrollViewDidEndDragging:willDecelerate:
    

    UIScrollViewDelegate method. When the willDecelerate: parameter is NO, the movement has stopped.

提交回复
热议问题