how can we use UICollectionView without an UICollectionViewController

被刻印的时光 ゝ 提交于 2019-12-24 11:09:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!