invalid nib registered for identifier (CELLNAME) - nib must contain exactly one top level object which must be a UITableViewCell instance

I had the same problem as above but I wasn't using storyboards and the problem just appeared out of the blue.

I found that the solution was in the tableview cell file. I had added a uibutton, but it had been added outside the bounds of the cell by mistake. This meant it was almost like an extra view in the uiview.

Once I found it and deleted this extra view the problem disappeared immediately.

If you have having this error, check the uitableviewcell for extra views and objects added by mistake


The answer of simon_smiley pointed me to the right direction, but some more trial-and-error was needed leading to the following solution:

The problem doesn't only occur for additional top-level UIView objects, but also for gesture recognizers. So make sure not to use any gesture recognizers in your failing XIB file, you can set them up in code instead.

For example you can do it in awakeFromNib as noted by vahotm in the accepted answers comments.


I had the same problem! And in my case custom cell was the subclass of UIView by mistake instead of UITableViewCell. So replacing UIView with UITableViewCell fixed the problem!