Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a UIActivityIndicatorView to footer of UICollectionView?

How do I add a UIActivityIndicatorView to footer of UICollectionView in swift? For UITableView, it was just self.tableView.tableFootView = self.myActivityIndicatorView. Is this possible? If so, how?

like image 810
iamarnold Avatar asked May 05 '16 20:05

iamarnold


People also ask

How to add loading indicator in footer of collectionView in iOS?

In Attribute inspector with your Collection View selected check the Section Footer in Accessories . So, It will add footerview in your collection view and you can easily drag and drop activity indicator to this footerView .

How do you add header and footer view in Uicollectionview?

Select the Collection Reusable View of the header, set the identifier as “HeaderView” in the Attributes inspector. For the Collection Reusable View of the footer, set the identifier as “FooterView”.

What is viewForSupplementaryElementOfKind?

collectionView(_:viewForSupplementaryElementOfKind:at:)Asks your data source object to provide a supplementary view to display in the collection view.


1 Answers

Create view class and add activity indication in that view

Register this class as footer view class using:

registerClass(myFooterViewClass, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: "myFooterView")

Either set the headerReferenceSize on your collection view layout or implement

collectionView:layout:referenceSizeForHeaderInSection: in your delegate.

Return the footer view from the following method in your dataSource:

func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
let view = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionFooter, withReuseIdentifier: "myFooterView", forIndexPath: indexPath)
// configure footer view
return view
}
like image 52
Moinuddin Girach Avatar answered Oct 22 '22 15:10

Moinuddin Girach