Add button at the end of collection view in storyboard

后端 未结 2 377
借酒劲吻你
借酒劲吻你 2020-12-10 09:09

I have a UICollectionViewController in a storyboard. I know how to add cells and modify them but for some reason I can\'t add any other view or UI element after

2条回答
  •  时光取名叫无心
    2020-12-10 10:10

    Swift 2.1 Solution :

    In Storyboard select Collection View > Attributes Inspector > Enabled Section Footer

    Once that is enabled, a section view will appear, and you can drag your views to it.

    Select the header view, and set the Identifier. ex :FooterViewID

    Next, In you related view controller file,write :

    func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
        let footerView = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "FooterViewID", forIndexPath: indexPath)
        return footerView
    }
    

    The footer now should appear in your interface bottom.

提交回复
热议问题