ios - Swift 3 Segue from UICollectionView Cell -


hi i'm beginner , stuck on basic segue! want find out correct syntax use sender e.g sandals[indexpath.row]sandalname thanks

override func collectionview(_ collectionview: uicollectionview, cellforitemat indexpath: indexpath) -> uicollectionviewcell {     let cell = collectionview.dequeuereusablecell(withreuseidentifier: "cell", for: indexpath) as! shoecollectionviewcell     let sandalcell = sandals[indexpath.row]     cell.sandalimage.image = uiimage(named: sandalcell["image"]!)     cell.sandalstylename.text = sandalcell["stylename"]     cell.sandalprice.text = sandalcell["price"]     return cell }  override func prepare(for segue: uistoryboardsegue, sender: any?) {     if segue.identifier == "shoedetailsegue"{         var detailpage = segue.destination as! shoedetailviewcontroller         let selectedcell = sender as! uicollectionviewcell         let indexpath = collectionview?.indexpath(for: cell)         detailpage.getname = sandals[indexpath!.row].sandalname         detailpage.getprice = sandals[indexpath!.row].sandalprice         detailpage.getimage = sandals[indexpath!.row].sandalimage     } } 

if want pass value segue need access array subscript same way doing in cellforitemat.

override func prepare(for segue: uistoryboardsegue, sender: any?) {     if segue.identifier == "shoedetailsegue"{          var detailpage = segue.destination as! shoedetailviewcontroller         let selectedcell = sender as! uicollectionviewcell         let indexpath = collectionview?.indexpath(for: cell)         let sandal = sandals[indexpath!.row]         detailpage.getname = sandal["stylename"]!         detailpage.getprice = sandal["price"]!         detailpage.getimage = uiimage(named: sandal["image"]!)     } } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -