Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS5 Storyboard: Reuse Custom UITableViewCell in multiple UITableViewControllers
    text
    copied!<p>Using a dynamic, custom cell prototype that I design in, say, <strong>UITableViewController A</strong> (in Interface Builder/Storyboard), works really well with dequeuing the cell (through its identifier, <strong>cellA</strong>) and such in cellForRow... I use a custom class (UITableViewCell subclass, let's name it <strong>MyCustomCell</strong>) to link up the labels and image thumb and it works all pretty well and straight forward in my <strong>UITableViewController A</strong>.</p> <p>Now I create a <strong>UITableViewController B</strong> (in Storyboard), which happens to have the exact same design/functionality for its custom cells (dynamic cells). So I switch the class of these cells to the <strong>MyCustomCell</strong> and give it a new identifier, <strong>cellB</strong>. </p> <p>In <strong>UITableViewController B</strong>, I dequeue the cell in cellForRow... and use the new identifier <strong>cellB</strong>. Note: Using <strong>cellA</strong> here leads to a crash, more or less obviously.</p> <p>But when the table view shows up, while running the app, the <strong>UITableViewController A</strong> works just fine, and the almost identical <strong>UITableViewController B</strong> does not work (empty cells). </p> <p>In Storyboard, it looks sort of off a bit, because the custom cell is designable within the <strong>UITableViewController A</strong> but in <strong>UITableViewController B</strong>, it's just a simple, plain cell. Despite the class associated to <strong>MyCustomCell</strong>.</p> <p>How would one avoid copy&amp;pasting these cells to the other controller (and therefore heavily going back and forth between copies when making design changes) – and rather just properly re-use it?</p>
 

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