问题
Normaly, if we want to use UICollectionView, we must use an UICollectionViewController. But now I don't want, so how can I use UICollectionView without an UICollectionViewController?
回答1:
Of course you can use a UICollectionView without an UICollectionViewController.
Just create a UICollectionViewLayout of your choice, and then call
- (id)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout
to create a new instance of UICollectionView. Don't forget to set the delegate and datasource of the UICollectionView to your class, and implement the UICollectionViewDataSource protocol.
Hope that helps.
来源:https://stackoverflow.com/questions/14291889/how-can-we-use-uicollectionview-without-an-uicollectionviewcontroller