Strategy to lazy load images for buttons within UIScrollView?
        Posted  
        
            by greypoint
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by greypoint
        
        
        
        Published on 2010-04-17T16:48:09Z
        Indexed on 
            2010/04/17
            16:53 UTC
        
        
        Read the original article
        Hit count: 944
        
I have a horizontal UIScrollView that contains UIButtons (though it could be any object). I would like to only download images for these buttons as the user scrolls and they are seen. I would also like an activityindicator running on each button while the images are downloading. Here's what I've tried with results:
Check content offset of uiscrollview and download images for visible buttons. Problem: issues getting activity view shown within subclassed UIButton and not desired usability since images are only downloaded once scrolling stops.
Add subviews (not buttons) to the UIScrollview hoping to use the view's ViewController to initiate a downloaded on viewDidAppear. Problem: viewDidAppear never seems to get called (because I am using addSubView?).
I've seen other apps that do this kind of loading but need some guidance on the typical set-up. Ebay's app is a great example. All items have a default image until the item comes into view, then an activityindicator runs and the items unique image is downloaded.
Thanks for assistance.
© Stack Overflow or respective owner