ios - Custom Footer view for UICollectionview in swift -
i re-writting objective-c app of min in swift , decided collection view works better tableview in case. have collectionview set how want , need add footer collection view.
in objective-c easy me, did create uiview, add objects it, , add tableview this.
self.videotable.tablefooterview = footerview;
now i've been trying in collection view similar solution, i've had no luck far.
is there simple .collectionviewfooterview or can add uiview to?
edit found similar ideas here if helps create answer
edit
i've been thinking on ways achieve right idea add footer view end of collection view using following code:
var collectionheight = self.collectionview.collectionviewlayout.collectionviewcontentsize().height footerview.frame = cgrectmake(0, collectionheight, screensize.width, 76)
the issue i'm having workaround need add more space contentview of colletionview , having no luck that
my solution
i solved using work-around (not prettiest works), add uiview uicollectionview using simple
footerview.frame = cgrectmake(0, collectionheight - 50, screensize.width, 50) self.collectionview.addsubview(footerview)
and set layout insets using this:
allayout.contentinsets = uiedgeinsetsmake(2, 2, 52, 2)
collection views handle headers , footers differently table views. you'll need to:
register footer view class using:
registerclass(myfooterviewclass, forsupplementaryviewofkind: uicollectionelementkindsectionfooter, withreuseidentifier: "myfooterview")
either set
headerreferencesize
on collection view layout or implementcollectionview:layout:referencesizeforheaderinsection:
indelegate
.return footer view following method in
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 }
i think that's everything!
Comments
Post a Comment