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

后端 未结 14 2167
情书的邮戳
情书的邮戳 2020-12-14 00:03

Sorry for the long title, but I wanted it to be clearly seen from a google search. Also, this differs from many of the other similar questions on here as its not specifying

相关标签:
14条回答
  • 2020-12-14 00:19

    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

    0 讨论(0)
  • 2020-12-14 00:21

    I'll put up my dumb solution for the sake of googlers...

    This was my personal dumb mistake - when I created a new custom cell for my table view, I went to the top level directory of my project -> add new file -> and created an Empty File type under the OS X section rather than the iOS section.

    Hopefully, most people have the other issue described above since it's less embarrassing :P

    0 讨论(0)
  • 2020-12-14 00:21

    In my case, I had an extra ImageView inside the xib added by mistake. Removed it and everything worked perfectly.

    0 讨论(0)
  • 2020-12-14 00:30

    I solved this by setting the class name in interface builder to match the cell reuse identifier (for that class) in interface builder.

    Note: I'm not saying the class and identifier have to be the same. I'm saying they need to link the corresponding view and backing model.

    0 讨论(0)
  • 2020-12-14 00:32

    Same problem because I drag and drop a UITapGestureRecognizer on the subviews of ContentView. Just remove it.

    0 讨论(0)
  • 2020-12-14 00:33

    Sometimes you using storyboard and have collectionView inside it and collectionView as well. After that you decide to simplified your Storyboard and divide cell into another nib. You create empty nib, Ctrl+C from storyboard -> Ctrl+V into nib.

    Everything looks fine but you'll have Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'invalid nib registered for identifier (PrettyCollectionViewCell) - nib must contain exactly one top level object which must be a UICollectionReusableView instance'

    Ansver: do not do this. After I clean nib and add all of elements as I've in Storyboard - it fixed.

    Seems like Bug of xCode IB - Version 7.3.1 (7D1014)

    0 讨论(0)
提交回复
热议问题