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:

transition starting @ 0 @ full speed

for part, looks good. however, if start tap on element other zero, happens:

transition starting @ 4 @ full speed

i can't figure out why goes through transition , snaps showing 0 element first.

here's looks after turning on slow transitions in sim:

transition starting @ 4 @ slow speed

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

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -