【问题标题】:How do I add a UIActivityIndicatorView to footer of UICollectionView?如何将 UIActivityIndi​​catorView 添加到 UICollectionView 的页脚?
【发布时间】:2016-08-31 18:41:33
【问题描述】:

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

【问题讨论】:

    标签: swift uicollectionview footer uiactivityindicatorview


    【解决方案1】:

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

    使用以下方法将此类注册为页脚视图类:

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

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

    collectionView:layout:referenceSizeForHeaderInSection: in your delegate.
    

    从数据源中的以下方法返回页脚视图:

    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
    }
    

    【讨论】:

      猜你喜欢
      • 2010-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多