Note that there are some explanatory texts on larger screens.

plurals
  1. POGet notified when UITableView has finished asking for data?
    primarykey
    data
    text
    <p>Is there some way to find out when a <code>UITableView</code> has finished asking for data from its data source?</p> <p>None of the <code>viewDidLoad</code>/<code>viewWillAppear</code>/<code>viewDidAppear</code> methods of the associated view controller (<code>UITableViewController</code>) are of use here, as they all fire too early. None of them (entirely understandably) guarantee that queries to the data source have finished for the time being (eg, until the view is scrolled).</p> <p>One workaround I have found is to call <code>reloadData</code> in <code>viewDidAppear</code>, since, when <code>reloadData</code> returns, the table view <em>is</em> guaranteed to have finished querying the data source as much as it needs to for the time being.</p> <p>However, this seems rather nasty, as I assume it is causing the data source to be asked for the same information twice (once automatically, and once because of the <code>reloadData</code> call) when it is first loaded.</p> <p>The reason I want to do this at all is that I want to preserve the scroll position of the <code>UITableView</code> - but right down to the pixel level, not just to the nearest row.</p> <p>When restoring the scroll position (using <code>scrollRectToVisible:animated:</code>), I need the table view to already have sufficient data in it, or else the <code>scrollRectToVisible:animated:</code> method call does nothing (which is what happens if you place the call on its own in any of <code>viewDidLoad</code>, <code>viewWillAppear</code> or <code>viewDidAppear</code>).</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.
 

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