'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier cell [duplicate] - ios

I am creating an app with a UITableViewController but I am getting the error:
'unable to dequeue a cell with identifier cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
I don't understand how I to find the solution and fix it.
2018-09-15 01:28:28.609848+0300 Yemekler[6554:482441] *** Assertion failure in -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.54.4/UITableView.m:7879
2018-09-15 01:28:28.613237+0300 Yemekler[6554:482441] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0 CoreFoundation 0x0000000112f461e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x000000010f3ac031 objc_exception_throw + 48
2 CoreFoundation 0x0000000112f4b472 +[NSException raise:format:arguments:] + 98
3 Foundation 0x000000010ee4f652 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x000000010fd8a496 -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 879
5 UIKit 0x000000010fd8a0f3 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 91
6 Yemekler 0x000000010ea9de72 _T08Yemekler17YemekTarifleriTVCC9tableViewSo07UITableF4CellCSo0gF0C_10Foundation9IndexPathV12cellForRowAttF + 226
7 Yemekler 0x000000010ea9e34c _T08Yemekler17YemekTarifleriTVCC9tableViewSo07UITableF4CellCSo0gF0C_10Foundation9IndexPathV12cellForRowAttFTo + 92
8 UIKit 0x000000010fda5567 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 783
9 UIKit 0x000000010fda5ae4 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
10 UIKit 0x000000010fd6ceaa -[UITableView _updateVisibleCellsNow:isRecursive:] + 3168
11 UIKit 0x000000010fd8d7e0 -[UITableView layoutSubviews] + 176
12 UIKit 0x000000010fd177a8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515
13 QuartzCore 0x00000001166b5456 -[CALayer layoutSublayers] + 177
14 QuartzCore 0x00000001166b9667 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
15 QuartzCore 0x00000001166400fb _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 343
16 QuartzCore 0x000000011666d79c _ZN2CA11Transaction6commitEv + 568
17 UIKit 0x000000010fc62269 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 141
18 CoreFoundation 0x0000000112ee8b0c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
19 CoreFoundation 0x0000000112ecd2db __CFRunLoopDoBlocks + 331
20 CoreFoundation 0x0000000112ecca84 __CFRunLoopRun + 1284
21 CoreFoundation 0x0000000112ecc30b CFRunLoopRunSpecific + 635
22 GraphicsServices 0x000000011583ea73 GSEventRunModal + 62
23 UIKit 0x000000010fc48057 UIApplicationMain + 159
24 Yemekler 0x000000010ea9c077 main + 55
25 libdyld.dylib 0x0000000114127955 start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

You need to register the table with a cell before dequeue in viewDidLoad with xib
tableView.register(UINib(nibName: "TableCell", bundle: nil), forCellReuseIdentifier: "cell")
OR
tableView.register(TableCell.self, forCellReuseIdentifier: "cell")
It's clear here from the crash
unable to dequeue a cell with identifier cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

As #Sh_Khan pointed out. You can register the cell in code or you can also register the reuse identifier in Storyboard, if you are using prototype cells.

Related

Terminating with uncaught exception of type NSException Xcode

I have a problem when I follow this tutorial. It doesn't work. Can anyone help me fix this error? This tutorial uses Swift 4, iOS 11, and Xcode 9 but I used iOS 12 and Xcode 10.1. Did that cause the problem? Because I just followed the tutorial correctly.
Here is the error message:
2019-03-09 22:27:39.775603+0700 Ratings[667:8658] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
2019-03-09 22:27:40.020185+0700 Ratings[667:8658] *** Assertion failure in -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UITableView.m:8054
2019-03-09 22:27:40.062689+0700 Ratings[667:8658] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier PlayerCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ed561bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010d399735 objc_exception_throw + 48
2 CoreFoundation 0x000000010ed55f42 +[NSException raise:format:arguments:] + 98
3 Foundation 0x000000010cd9c877 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
4 UIKitCore 0x00000001119ec5b1 -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 868
5 UIKitCore 0x00000001119ec219 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 91
6 Ratings 0x000000010ca6f950 $S7Ratings21PlayersViewControllerC05tableC0_12cellForRowAtSo07UITableC4CellCSo0jC0C_10Foundation9IndexPathVtF + 240
7 Ratings 0x000000010ca6fd9c $S7Ratings21PlayersViewControllerC05tableC0_12cellForRowAtSo07UITableC4CellCSo0jC0C_10Foundation9IndexPathVtFTo + 108
8 UIKitCore 0x0000000111a0766e -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 771
9 UIKitCore 0x0000000111a07bfb -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 73
10 UIKitCore 0x00000001119cec36 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2863
11 UIKitCore 0x00000001119ef8ee -[UITableView layoutSubviews] + 165
12 UIKitCore 0x0000000111cad795 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1441
13 QuartzCore 0x0000000113235b19 -[CALayer layoutSublayers] + 175
14 QuartzCore 0x000000011323a9d3 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
15 QuartzCore 0x00000001131b37ca _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 342
16 QuartzCore 0x00000001131ea97e _ZN2CA11Transaction6commitEv + 576
17 UIKitCore 0x00000001117de2d0 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 139
18 CoreFoundation 0x000000010ecbb62c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
19 CoreFoundation 0x000000010ecbade0 __CFRunLoopDoBlocks + 336
20 CoreFoundation 0x000000010ecb5654 __CFRunLoopRun + 1284
21 CoreFoundation 0x000000010ecb4e11 CFRunLoopRunSpecific + 625
22 GraphicsServices 0x0000000116f541dd GSEventRunModal + 62
23 UIKitCore 0x00000001117c381d UIApplicationMain + 140
24 Ratings 0x000000010ca6e547 main + 71
25 libdyld.dylib 0x00000001102d0575 start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
You can find my source code on my github repo here.
You defined cell identifier as PlayersCell in storyboard.
change it to PlayerCell
Please read the error message carefully. The most significant parts are
unable to dequeue a cell with identifier PlayerCell
and the line before the NSAssertionHandler handleFailureInMethod line which indicates where the error occurs:
0x00000001119ec5b1 -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 868
It means that the reuse identifier of the table view cell in Interface Builder is not set or doesn't match the identifier specified in cellForRow in your case a simple typo.

Xib file as a Custom TableView Cell crashes

I am using Xib file as a custom Tableview Cell. But everytime i run my application, it crashes. I get this crash logs which i posted below
* Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UITableView.m:6730
2017-12-04 17:23:16.070 iCommander[2489:135476] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0 CoreFoundation 0x00000001035f6b0b exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010305b141 objc_exception_throw + 48
2 CoreFoundation 0x00000001035facf2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000102bf5536 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x00000001042eae45 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 241
5 iCommander 0x0000000101e6b43f _TFC10iCommander25CommentsHistoryController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 303
6 iCommander 0x0000000101e6ba07 _TToFC10iCommander25CommentsHistoryController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 87
7 UIKit 0x00000001042fdab2 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 750
8 UIKit 0x00000001042fdcf8 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
9 UIKit 0x00000001042d2639 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2845
10 UIKit 0x0000000104306ccc -[UITableView _performWithCachedTraitCollection:] + 111
11 UIKit 0x00000001042ede7a -[UITableView layoutSubviews] + 233
12 UIKit 0x000000010425455b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
13 QuartzCore 0x0000000102429904 -[CALayer layoutSublayers] + 146
14 QuartzCore 0x000000010241d526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
15 QuartzCore 0x000000010241d3a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
16 QuartzCore 0x00000001023ace92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
17 QuartzCore 0x00000001023d9130 _ZN2CA11Transaction6commitEv + 468
18 QuartzCore 0x00000001023d9b37 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 115
19 CoreFoundation 0x000000010359c717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
20 CoreFoundation 0x000000010359c687 __CFRunLoopDoObservers + 391
21 CoreFoundation 0x0000000103581720 __CFRunLoopRun + 1200
22 CoreFoundation 0x0000000103581016 CFRunLoopRunSpecific + 406
23 GraphicsServices 0x00000001091e1a24 GSEventRunModal + 62
24 UIKit 0x0000000104191134 UIApplicationMain + 159
25 iCommander 0x0000000101e13ea7 main + 55
26 libdyld.dylib 0x000000010743e65d start + 1
27 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Please help. Thanks in advance.
You forgot to register the XIB file. You have to register the xib file for getting rid of the crash.
In Swift 3
let xib = UINib(nibName: "YourCustomCell", bundle: nil)
tableView.register(xib, forCellReuseIdentifier: "Cell")
You should register the custom cell like that.
Hope it helps.
Set cell identifier to custom cell in xib file as:
IN Swift 3
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = Bundle.main.loadNibNamed("XibName", owner: self, options: nil)?.first as! XibName
return cell
}

UITableView throwing NSUnkownKeyException on creation of cell

I have really been struggling to fix this NSUnkownKeyException I am getting now upon creation of a cell in my UITableView. This is the line of code causing the error:
let cell = tableView.dequeueReusableCellWithIdentifier("eventCell", forIndexPath: indexPath) as! EventTableViewCell
ACTUAL ERROR:
2016-07-08 19:08:58.879 myApp[15078:1230258] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<myApp.EventTableViewCell 0x7fbed3811000> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c143d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010df1fdeb objc_exception_throw + 48
2 CoreFoundation 0x000000010c1439c9 -[NSException raise] + 9
3 Foundation 0x000000010c51519b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x000000010ca264b6 -[UIView(CALayerDelegate) setValue:forKey:] + 173
5 UIKit 0x000000010cd357fb -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010c07d890 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x000000010cd341de -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x000000010cab595f -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 428
9 UIKit 0x000000010cab5e32 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 71
10 myApp 0x000000010a81735a _TFC15firebaseTestApp16CEViewController9tableViewfTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 330
11 myApp 0x000000010a817ccf _TToFC15firebaseTestApp16CEViewController9tableViewfTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 79
12 UIKit 0x000000010cac94f4 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 766
13 UIKit 0x000000010cac962c -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
14 UIKit 0x000000010ca9dd4f -[UITableView _updateVisibleCellsNow:isRecursive:] + 2996
15 UIKit 0x000000010cad2686 -[UITableView _performWithCachedTraitCollection:] + 92
16 UIKit 0x000000010cab9344 -[UITableView layoutSubviews] + 224
17 UIKit 0x000000010ca26980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
18 QuartzCore 0x0000000111a60c00 -[CALayer layoutSublayers] + 146
19 QuartzCore 0x0000000111a5508e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
20 QuartzCore 0x0000000111a54f0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
21 QuartzCore 0x0000000111a493c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
22 QuartzCore 0x0000000111a77086 _ZN2CA11Transaction6commitEv + 486
23 QuartzCore 0x0000000111a777f8 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
24 CoreFoundation 0x000000010c068c37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
25 CoreFoundation 0x000000010c068ba7 __CFRunLoopDoObservers + 391
26 CoreFoundation 0x000000010c05e7fb __CFRunLoopRun + 1147
27 CoreFoundation 0x000000010c05e0f8 CFRunLoopRunSpecific + 488
28 GraphicsServices 0x000000010f218ad2 GSEventRunModal + 161
29 UIKit 0x000000010c96bf09 UIApplicationMain + 171
30 myApp 0x000000010a834bf2 main + 114
31 libdyld.dylib 0x000000010e9fa92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Things i checked:
TableView is initialized to the proper class
TableView is connected to UITableViewController
I have checked every outlet I could find to make sure there were not any misconnections or empty connections.
Thank you so much for help, all is appreciated!
dequeueReusableCellWithIdentifier is attempting to instantiate an EventTableViewCell from a .xib it sounds like that file contains an invalid binding which is attempting to set a view property (which does not exist) on the EventTableViewCell. Look at your xib in Xcode, you probably have warnings about invalid outlet bindings.
you should select tableview cell in nib/storyboard and check Outlets in utilities panel.If any broken outlet comes to cell Xcode will put bang mark to connection node.For finding xib/storyboard you should search in xcode with EventTableViewCell

UICollectionViewController not working in upgraded XCode 7 project

I am working on a project that uses storyboards and was started in XCode 6 and has been upgraded to XCode 7. I am trying to add a UICollectionViewController. I get an exception on this line: let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! UnsplashCollectionViewCell
I have verified that the controller and cell are both assigned to my custom class in the storyboard, and that my reuse identifier is assigned to the cell and the same as the variable reuseIdentifier in my controller class.
About the only difference I can tell between a working UICollectionViewController and this project's is if I start a new project and add a UICollectionViewController I get the following in the Connections Inspector:
However, the Connections Inspector in my broken project looks like:
I'm not sure this is the problem, but I'm at a loss for what else it could be.
Crash log:
Uncaught exception: could not dequeue a view of kind: UICollectionElementKindCell with identifier UnsplashCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard
Full Crash Log:
2016-03-14 10:34:55.027 PixelSquidTouch[86881:2845927] [Crashlytics] Version 3.4.1 (92)
2016-03-14 10:34:55.063 PixelSquidTouch[86881:] App measurement v.1201000 started
2016-03-14 10:35:02.990 PixelSquidTouch[86881:2845927] *** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.30.14/UICollectionView.m:3690
2016-03-14 10:35:03.013 PixelSquidTouch[86881:2845927] WARNING: GoogleAnalytics 3.14 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:48): Uncaught exception: could not dequeue a view of kind: UICollectionElementKindCell with identifier UnsplashCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard
2016-03-14 10:35:08.054 PixelSquidTouch[86881:2845927] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier UnsplashCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c95ce65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010ffb0deb objc_exception_throw + 48
2 CoreFoundation 0x000000010c95ccca +[NSException raise:format:arguments:] + 106
3 Foundation 0x000000010fa274de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 UIKit 0x000000010ddd04e9 -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] + 2009
5 UIKit 0x000000010ddd0945 -[UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:] + 169
6 PixelSquidTouch 0x000000010b8d9e6a _TFC15PixelSquidTouch32UnsplashCollectionViewController14collectionViewfS0_FTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 122
7 PixelSquidTouch 0x000000010b8d9f8f _TToFC15PixelSquidTouch32UnsplashCollectionViewController14collectionViewfS0_FTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 79
8 UIKit 0x000000010ddc05ba -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:] + 483
9 UIKit 0x000000010ddc2ae0 -[UICollectionView _updateVisibleCellsNow:] + 4431
10 UIKit 0x000000010ddc723b -[UICollectionView layoutSubviews] + 247
11 UIKit 0x000000010d6224a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
12 QuartzCore 0x000000010f41759a -[CALayer layoutSublayers] + 146
13 QuartzCore 0x000000010f40be70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
14 QuartzCore 0x000000010f40bcee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
15 QuartzCore 0x000000010f400475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
16 QuartzCore 0x000000010f42dc0a _ZN2CA11Transaction6commitEv + 486
17 UIKit 0x000000010d596b47 _afterCACommitHandler + 174
18 CoreFoundation 0x000000010c888367 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
19 CoreFoundation 0x000000010c8882d7 __CFRunLoopDoObservers + 391
20 CoreFoundation 0x000000010c87df2b __CFRunLoopRun + 1147
21 CoreFoundation 0x000000010c87d828 CFRunLoopRunSpecific + 488
22 GraphicsServices 0x000000011197cad2 GSEventRunModal + 161
23 UIKit 0x000000010d56b610 UIApplicationMain + 171
24 PixelSquidTouch 0x000000010b957aad main + 109
25 libdyld.dylib 0x0000000110b5692d start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
So, you are trying to dequeue a cell but there is no cell with that ID. You need to open the cell in the storyboard or Xib and set the UICollectionElementKindCell ID to that id UnsplashCell
If you havent done the cell in the storyboard as a prototype cell, but are using a xib file, then you also need to register that cell with the tableview, so it knows about the cell type.
in your viewDidLoad:
let nibName = UINib(nibName: "UICollectionElementKindCell", bundle:nil)
self.tableView.registerNib(nibName, forCellReuseIdentifier: "UnsplashCell")
Update:
Look at the objects outlets etc. in the storyboard with the VC selected.
I am also struggling with this same issue since upgrading to XCode 7 last week. In our case, we were disabling user interaction whenever we displayed an activity view:
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
Then, in a callback block we were re-enabling user interaction with this:
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
Removing these calls resolved three out of four of these issues in our code; hopefully it can fix your issue as well. In any event, we haven't come up with a better approach as of yet.

How to detect a collectionview is out of screen and return it to its initial scroll position?

I am having a problem with a CollectionView in a TableView. The CollectionView contains a bunch of action buttons. You can scroll through them horizontally. Tableview contains some other views and our CollectionView. You can scroll this TableView vertically.
It works fine until you scroll a CollectionView a little, leave it like that, then Scroll the main TableView. After that TableView cell goes out of screen, app crashes with this message:
2016-01-22 10:19:30.008 Cool[1807:31453] *** Assertion failure in -[UICollectionViewData validateLayoutInRect:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.29.5/UICollectionViewData.m:399
2016-01-22 10:19:30.052 Cool[1807:31453] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0x7ae57380> {length = 2, path = 0 - 3}'
*** First throw call stack:
(
0 CoreFoundation 0x00aa2a84 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02b7ee02 objc_exception_throw + 50
2 CoreFoundation 0x00aa291a +[NSException raise:format:arguments:] + 138
3 Foundation 0x010e4e86 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 118
4 UIKit 0x02081c79 __45-[UICollectionViewData validateLayoutInRect:]_block_invoke + 1116
5 UIKit 0x02080c1f -[UICollectionViewData validateLayoutInRect:] + 1329
6 UIKit 0x0202694b -[UICollectionView layoutSubviews] + 188
7 UIKit 0x01790eb7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 813
8 libobjc.A.dylib 0x02b93059 -[NSObject performSelector:withObject:] + 70
9 QuartzCore 0x0159280a -[CALayer layoutSublayers] + 144
10 QuartzCore 0x015864ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
11 QuartzCore 0x01586352 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
12 QuartzCore 0x01578e8b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
13 QuartzCore 0x015ace03 _ZN2CA11Transaction6commitEv + 561
14 QuartzCore 0x015ae674 _ZN2CA11Transaction17flush_transactionEv + 50
15 QuartzCore 0x015bdc4f _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 593
16 QuartzCore 0x015be0b5 _ZN2CA7Display16TimerDisplayLink8callbackEP16__CFRunLoopTimerPv + 123
17 CoreFoundation 0x009f4576 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
18 CoreFoundation 0x009f3f72 __CFRunLoopDoTimer + 1250
19 CoreFoundation 0x009b225a __CFRunLoopRun + 2202
20 CoreFoundation 0x009b1706 CFRunLoopRunSpecific + 470
21 CoreFoundation 0x009b151b CFRunLoopRunInMode + 123
22 GraphicsServices 0x04486664 GSEventRunModal + 192
23 GraphicsServices 0x044864a1 GSEventRun + 104
24 UIKit 0x016c71eb UIApplicationMain + 160
25 Cool 0x00036ddc main + 140
26 libdyld.dylib 0x0729aa21 start + 1
27 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What I have is mind is when a CollectionView is out of screen, return it to its initial scroll position to avoid the crash. So how do I detect that? Is there any other solutions?
I ended up implementing didEndDisplayingCell and it worked. Here is the solution:
override func tableView(tableView: UITableView, didEndDisplayingCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let mycell = cell as! MyCell
mycell.collectionView.setContentOffset(CGPointZero, animated: false)
}

Resources