4

In storyboards using a static content tableview. I've added a tableview cell. In it I've added a view and a label. When I assign the view as the cell's backgroundView (ctrl+click & drag from the cell to the view) I get the following error at run after loading the tableview.

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableViewCell's implementation of -layoutSubviews needs to call super.'

If I remove the association, it runs without issue.

Has anyone had any experience with this error?

Adam Ritenauer
  • 3,151
  • 4
  • 33
  • 40
  • Are you using a custom UITableViewCell? "UITableViewCell's implementation of -layoutSubviews needs to call super." is pretty telling. If not, please provide code. – WDUK Oct 26 '12 at 21:01
  • No I am not. It's a static table in story boards. Fairly vanilla by all accounts. – Adam Ritenauer Oct 31 '12 at 02:36
  • I reproduced this issue with a fresh project, a single UITableViewController, and a single static UITableView. If you add a cell to it, then a UIView to that cell, link the view to the cells backgroundView property, and run the application, you'll get this error – Adam Ritenauer Oct 31 '12 at 03:25
  • The problem is with auto layout. Disabling auto layout for the VC eliminates the problem. Though this is not a solutions by any means. The follow question goes into more detail on the issue http://stackoverflow.com/questions/12610783/auto-layout-still-required-after-executing-layoutsubviews-with-uitableviewcel – Adam Ritenauer Oct 31 '12 at 03:28

1 Answers1

0

I'm going to make a guess that is the one rare time where a view is treated as being included twice in a view hierarchy. When layout is performed, it goes through the normal view heir achy and lays out the view, but then (or before that) it lays out the background view hierarchy as well. This would HAVE to result in a layout error.

The solution? Growl at apple and ignore it. Disconnect the view from the backgroundView property and just deal with it as a view. This works for me. I don't see any great advantage in connecting it.

Owen Godfrey
  • 3,361
  • 2
  • 22
  • 18