Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem updating UITableViewCells when rotating UITableView
    primarykey
    data
    text
    <p>I have a UILabel in a custom UITableViewCell that gets resized when the device is rotated. The text in this label needs to be recalculated after the rotation because I am cutting it down to size and appending some text at the end.</p> <p>E.g. the datamodel has: "This is a run-on sentence that needs to stop."</p> <p>In portrait mode it becomes "This is a run-on sent... more"</p> <p>In landscape mode it becomes "This is a run-on sentence that... more"</p> <p>From <code>(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation</code> I am able to access the visible UITableViewCells and update the descriptions.</p> <p>The problem seems to be that there are UITableViewCells that are cached but I can't get to. When I scroll the UITableView after a rotation, one or two cells that are below the visible area after the rotation don't have the correct text in the label. So they haven't been rendered via <code>(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</code> - but they weren't returned by [tableView visibleCells] (or via looping through all views returned via [tableView subViews]).</p> <p>I've tried to access the "extra" cells via this method:</p> <pre><code>for (int index=max + 1; index &lt; max + 3 &amp;&amp; index &lt; [cellTypes count]; index++) { NSIndexPath *updatedPath = [NSIndexPath indexPathForRow:index inSection:0]; UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:updatedPath]; if (cell == nil) { continue; } [self updateCellForRotate:cell forRow:index]; } </code></pre> <p>(where max is the biggest row returned from visibleCells) but cell is always nil.</p> <p>Is there anyway to flush the cache of UITableViewCells so that they don't get re-used? Or to access them so I can update them?</p> <p>Thanks!</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.
 

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