Reputation: 2863
I am new for IOS development , and I try to use UIcollectionView
to show the photo.
I create a xib file
from New file -> iOS
-> User Interface
-> View
, and add a Collection View
like the following picture.
But I got the following error log when it crash.
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[UICollectionViewController loadView]
loaded the "AITLocalGridViewController" nib but didn't get a UICollectionView.'
And it seems didn't call viewDidLoad
I have search for some information , some information indicated that I dint not connect the collection view in xib file
But I don't understand what it mean.
Could some one help me and teach me what to do ?
Upvotes: 6
Views: 8471
Reputation: 553
Make sure UICollectionViewController's "view" outlet is set to a UICollectionView. Setting the "collectionView" to a UICollectionView is not enough for a UICollectionViewController.
Upvotes: 3
Reputation: 316
At the risk of stating the obvious, also make sure that the UICollectionView
is inside a UICollectionViewController
. This can be overlooked when you do something like adding an embedded view into your project, where the default embedded view is the standard view controller.
Upvotes: 2
Reputation: 129
Just remove the view in Storyboard and use the UICollectionView as direct child.
Upvotes: 3
Reputation: 137
Make sure that you have connected UIcollectionview
IBOutlet
with “collectionview
“ that you declared in your program. And also you should make delegate&data source connection(For making this, click on th Uicollectionview
in the xib. Select Connection Inspector. Where you can see delegate
and datasource
.By pressing ctrl button drag and connect it to File’s Owner.)
Upvotes: 4