0
안녕하세요 저는 초보자이며 아주 기본적인 segue에 갇혀 있습니다! 난 그냥 당신이 당신이 단순히 subscript
으로 배열에 접근 할 필요가 SEGUE로 값을 전달하려면 보낸 사람, 예를 들면 샌들 [indexPath.row] sandalName에 대한 감사Swift 3 UICollectionView 셀의 Segue
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
}
}
http://stackoverflow.com/a/41887007/5461400이 –
은 참고로 우리에게 sandals' 배열 –
'의 선언을 표시하려고 : 같은'var에 detailPage = segue.destination! shoeDetailViewController'는 'var detailPage = segue.destination as'이어야합니다! ShoeDetailViewController'는 잘못된 변수 이름 규칙을 무시합니다. – TheCodingArt