I am new to using UICollectionView. I have created a footer section in the collection view using flow layout, and want to add a UIButton there. How can I do that?
[flowLayout setFooterReferenceSize:CGSizeMake (320,50)];
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You supply the footer view in the same way you provide the cell views via the UICollectionViewDataSource object. The only diff is for the cell view you override
[UICollectionViewDataSource collectionView:cellForItemAtIndexPath:]and for the footer view you override[UICollectionViewDataSource collectionView:viewForSupplementaryElementOfKind:atIndexPath:].If you want to configure the footer view via the Interface Builder do this:
1.) Select the collectionView of your
UICollectionViewControllerin IB.2.) Click the attributes inspector button in the right panel.
3.) In the “Collection View” section enable the radio button titled “Section Footer”
This will add a footer subview to your collectionView that you can drag and drop a UIButton to.
Also if you are using
UICollectionViewFlowLayoutas your layout object you will need to set its footerReferenceSize property so that it knows how big the footer should be. If you don’t set this property the footer will not be displayed.