ios - prepareForSegue UICollectionView not working (swift) -
i’ve tried push segue using uicollectionview (show image form masterview deatilview) not working. xcode doesn’t show error message. what’s wrong code. need advice.
override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if segue.identifier == "showdetail" { if let indexpath = self.collectionview?.indexpathforcell(sender as! uicollectionviewcell) { let detailvc = segue.destinationviewcontroller as! detailmenuviewcontroller detailvc.picfood = self.collection[indexpath.row]
- collection empty array data form json
- [title = self.namefood.title], working in detailmenuviewcontroller.swift not image on code above.
you need add uicollecitonviewdelegate
func collectionview(collection: uicollectionview, selecteditemindex: nsindexpath) { self.performseguewithidentifier("showdetail", sender: self) }
after add
override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if segue.identifier == "showdetail" { if let indexpath = self.collectionview?.indexpathforcell(sender as! uicollectionviewcell) { let detailvc = segue.destinationviewcontroller as! detailmenuviewcontroller detailvc.picfood = self.collection[indexpath.row] } } }
Comments
Post a Comment