【发布时间】:2018-04-03 05:07:29
【问题描述】:
我有userDetails 数据。现在我想将didSelectItemAt IndexPath 中的userDetails 发送给另一个viewController。
如何做到这一点?
这是我的一段代码
var userDetails : UserDetails!
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCell", for: indexPath) as! CollectionViewCell
let imageUrl = URL(string: Constant.url.imageBaseUrl + userDetails.user_medias[indexPath.row].thumbnail_url)
cell.imgvw.kf.setImage(with: imageUrl)
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let vc = self.storyboard!.instantiateViewController(withIdentifier: Constant.vc.DetailsVC) as! DetailsVC
vc.userDetails = userList[indexPath.row]
self.show(vc, sender: self)
}
// in number of rows in section i am showing this
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return userDetails.user_medias.count
}
如何在userList 中嵌入userDetails 数据,以便我可以在indexpath 的didelcect 项目中发送数据
【问题讨论】:
-
在
didSelectItemAt你在最后一行调用了show func 那么什么是show func?? -
@dahiya_boy 。先生,请您详细说明
-
在
didSelectItemAt中,你在最后一行调用了 show func 那么 show func 是什么?? -
负责showViewController的@dahiya_boy
-
只想从字典中获取值作为数组?或将带有键及其值的完整字典转换为数组?
标签: ios arrays swift nsdictionary swift4