Note that there are some explanatory texts on larger screens.

plurals
  1. POGraphical glitches when adding cells and scrolling with UITableView
    primarykey
    data
    text
    <p>I am using a UITableView to display the results of a series of calculations. When the user hits 'calculate', I add the latest result to the screen. When I add a new cell, the <code>UITableViewCell</code> object is added to an array (which is indexed by <code>tableView:cellForRowAtIndexPath:</code>), and then I use the following code to add this new row to what is displayed on the screen:</p> <pre><code>[thisView beginUpdates]; [thisView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation: UITableViewRowAnimationFade]; [thisView endUpdates]; </code></pre> <p>This results in the new cell being displayed. However, I then want to immediately scroll the screen down so that the new cell is the lowermost cell on-screen. I use the following code:</p> <pre><code>[thisView scrollToRowAtIndexPath:newIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; </code></pre> <p>This <strong>almost</strong> works great. However, the first time a cell is added and scrolled to, it appears onscreen only briefly before vanishing. The view scrolls down to the correct place, but the cell is not there. Scrolling the view by hand until this invisible new cell's position is offscreen, then back again, causes the cell to appear - after which it behaves normally. This only happens the first time a cell is added; subsequent cells don't have this problem. It also happens regardless of the combination of <code>scrollToRowAtIndexPath</code> and <code>insertRowsAtIndexPath</code> animation settings.</p> <p><strong>EDIT:</strong> <em>I've now started inserting cells at the second-to-last position of the table, rather than the end, and the problem still occurs - when first inserted, a cell is 'invisible' until it goes offscreen and comes back on again. What could be causing this, and how can I force the cell to be drawn as soon as it is added to the table?</em></p>
    singulars
    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.
 

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