如何在UICollectionView的页脚中添加UIActivityIndi​​catorView?

时间:2016-05-05 20:29:27

标签: swift uicollectionview footer uiactivityindicatorview

如何在swift中向UIActivityIndicatorView的页脚添加UICollectionView?对于UITableView,它只是self.tableView.tableFootView = self.myActivityIndicatorView。这可能吗?如果是这样,怎么样?

1 个答案:

答案 0 :(得分:1)

创建视图类并在该视图中添加活动指示

使用以下命令将此类注册为页脚视图类:

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

在集合视图布局上设置headerReferenceSize或实现

collectionView:layout:referenceSizeForHeaderInSection: in your delegate.

在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
}