Storyboard static cells: dequeueReusableCellWithIdentifier returns nil

With static content in a table view, you do not implement any of the datasource methods (including tableView:cellForRowAtIndexPath:, so you would never dequeue the cells. There is no dequeuing for static content (that you can get involved in, anyway).

If you want to get a pointer to a particular cell:

  • get it from the table view using cellForRowAtIndexPath::

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    
  • have an outlet to the specific cell and customise it directly.

  • Iterate through the cells and check the reuseIdentifier property to get the cell you are interested in.

Any of these things can be done in viewWillAppear or similar.

If you want to have completely different content in your cells to that found on the storyboard then static cells probably aren’t the right choice. You should use dynamic prototypes (note you can have multiple prototypes in the storyboard) with the traditional data source methods instead.

Leave a Comment