ios - prepareForSegue is never called in UICollectionView -


good afternoon,

i'm trying perform segue collectionview prepareforsegue never triggered when touching cell. working tableview it's not collectionview.

as can see in code, have both in same viewcontroller, don't know why it's working tableview. "seguecollection" never triggered.

what have in order make work? there type of problem because i'm using tableview segue? i'm little bit lost here.

here code:

override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {     if segue.identifier == "showmoviefromtable", let destination = segue.destinationviewcontroller as? movieviewcontroller, index = tableview.indexpathforselectedrow?.row {         destination.year = searchmovies[index].year     } else if segue.identifier == "showmoviefromcollection" {         print("seguecollection")     }     print("seguetriggered") } 

i'm trying inside code (but it's not showing anything):

func collectionview(collectionview: uicollectionview, didselectitematindexpath indexpath: nsindexpath) {     print(indexpath)     self.performseguewithidentifier("showmoviefromcollection", sender: self) } 

thanks in advance,

regards.

i had same problem , got stuck there bit time. realize, instead of using prepareforsegue, have use prepare function.

override func prepare(for segue: uistoryboardsegue, sender: any?) {     if segue.identifier == "youridentifier" {         // stuff want     } } 

Comments