Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe you may have two problems here. First is the issue of not multi-threading the image loads and second is how you're using UITableViewCell.</p> <p>iPhone calls cellForRowAtIndexPath whenever a cell appears on the screen - if you scroll down, everything above is unloaded and reloaded when you scroll back up again. As already noted this can be solved with multithreading patterns - either the link posted to markj.net, and/or by using NSThread. The advantage of NSThread is you have more flexibility to handle problems or load more than just image data. (I would use both)</p> <p>In order to do this efficiently you need to have a custom UITableViewCell. This is good to have regardless because you can make the table cell responsible for it's content rather than your view controller, and you can efficiently manipulate cell formatting and content. Here is a link to a <strong>great</strong> post about UITableCellView: <a href="http://blog.atrexis.com/index.cfm/2009/1/6/iPhone--Customize-the-UITableCellView" rel="nofollow noreferrer">http://blog.atrexis.com/index.cfm/2009/1/6/iPhone--Customize-the-UITableCellView</a></p> <p>When you implement UITableViewCell, do your best to put all addSubView and formatting calls in the "if(cell==nil)" block, <strong>only</strong> if you can't put them in your custom initWithFrame. You'll find the iPhone is stacking every subview you add -- it's not clearing the old view. You can see this at work by setting all the background colors to "UIColor clearColor" and then change text between hits -- you'll see a stack of text on top of each other. This isn't normally visible because solid-filled backgrounds draw over all the "old" subviews.</p> <p>Before you combine these two methods, considering implementing a "model". You've got a view and a controller but all of your data should be in a model. All of the image URLs, content, etc. should be in something like an NSMutableArray, a custom object of your own, or maybe via SQLite. Once you have a model, you can implement your caching of the images. With caching, all of the images will be retained between loads of your application which will save batteries, bandwidth, and time.</p> <p>I would: 1. put all your data in a model of some kind (NSMutableArray, SQLLite, something) 2. Implement your own custom UITableViewCell 3. Make sure you have 0 addSubView, init, or alloc calls inside the active block of cellForRowAtIndexPath 4. Use delegation example or NSThread to load all images in the background 5. Add local image caching</p> <p>There are some good examples out in about and on the Apple forums on caching images.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload