ios - UICollectionView changing layout selected item and frame/constraints -
i've got collection view i'm dynamically changing between layout looks uitableview , layout looks sort of timemachine carousel i'm calling "swipelayout" (which doesn't swiping right now, eventually).
btw, entire project here: https://github.com/supertango/collectionviewlayoutswitching. under master branch tag "initial_question"
the initial layout table layout, when item tapped, change layout "swipelayout" animation (and again). in viewcontroller, have:
func collectionview(collectionview: uicollectionview, didselectitematindexpath indexpath: nsindexpath) { nslog("index path chosen: \(indexpath)") changelayouttapped(self) } @ibaction func changelayouttapped(sender: anyobject) { if (self.collectionview.collectionviewlayout == tablelayout) { self.collectionview.setcollectionviewlayout(swipelayout, animated: true) self.mode = mode.swipe } else { self.collectionview.setcollectionviewlayout(tablelayout, animated: true) self.mode = mode.table } }
the code swipelayout bit long, don't want put in question, here's link it: https://github.com/supertango/collectionviewlayoutswitching/blob/initial_question/collectionviewlayouts/swipelayout.swift
here's transition looks like:
for part, looks good. however, if start tap on element other zero, happens:
i can't figure out why goes through transition , snaps showing 0 element first.
here's looks after turning on slow transitions in sim:
i've tried setting selected element on collection view so:
func collectionview(collectionview: uicollectionview, didselectitematindexpath indexpath: nsindexpath) { nslog("index path chosen: \(indexpath)") self.swipelayout.startingitemindex = indexpath.item changelayouttapped(self) }
but no luck there.
any ideas?
extra bonus if can tell me how contents (the numbers inside) stay centered in middle of view during entire transition.
thanks.
Comments
Post a Comment