简体   繁体   中英

How to add collectionview as subview to viewcontroller

i had a little problem with my collectionview when i want to add it as a subview to my ProfileViewController. The problem occurred when i want to reload the collectionview and xcode give me an error property 'collectionview' not found on object of type ProfileViewController . how can i overcome this problem? do i to create a new collectionview class file and set it to collectionview on ProfileViewController ? Below is the image for my storyboard.

the image for storyboard is at this link. http://i.stack.imgur.com/XSE29.png . I can't attached an image to this post cause my reputation is low.

You'll want make sure your ProfileViewController conforms to the UICollectionViewDataSource and UICollectionViewDelegate protocols and when you create the collection view inside the ProfileViewController make sure you do:

collectionView.delegate = self;
collectionView.dataSource = self;

Sounds like you're trying to use self.collectionView, where that property doesn't exist on the ProfileViewController.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM