Note that there are some explanatory texts on larger screens.

plurals
  1. POThe right approach to loading dynamic content into a UITableView in iOS
    primarykey
    data
    text
    <p>ok, I've read tons of bits and pieces on the subject of loading dynamic content (from the web) into a UITableView and the problem with calculating cell height upfront. I've tried different simple implementations but the problem persists... </p> <p>Assuming I need to read a JSON file from the web, parse it into 'item' objects, each with variable size image and various text labels, <strong>here is what I believe would be the right approach to avoid long hang time of the app while everything is loading</strong>:</p> <ol> <li>on app load read JSON file and parse into items array</li> <li>provide only small part of the items array to the tableview (about 10 items) - since I need to load the images associated with each item to calculate cell height - I don't want the view to go through the whole items list and load all images - this hangs the app until every image is loaded</li> <li>display the tableview with the available cells (assuming I load a few 'spare' ones, user can even scroll to more items)</li> <li>in the background using Grand Central Dispatch download images for all/some of the remaining items and then reload the tableview with the new data (repeat step 4 if item list is very long)</li> </ol> <p>Step 2 above is necessary since I have no way to calculate the cell height without loading the images first, and since tableview first calculates height of all cells it may take a very long time to download all images for all items.</p> <p>Would you say this is the right approach? am I missing something?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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