我在主VC中有一个集合视图,需要将图像的url数据传递给其他VC
这是我的代码
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! EventAlbumCustom
let release = arrayOfRels[indexPath.row]
cell.pic.sd_setImageWithURL(NSURL(string: release.url))
return cell
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let Dest = segue.destinationViewController as! EventPhotoFullSize
if (segue.identifier == "eventphotofullsize") {
let cell = sender as! UICollectionViewCell
Dest.imageURL = cell.pic .....??
}
}
找不到单元格的imageview pic
和网址
答案 0 :(得分:0)
您无法找到在您的单元格中声明的属性,因为在prepareForSegue
中您将sender
转换为UICollectionViewCell
而不是您定义的EventAlbumCustom
,代码应该是这样的:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let Dest = segue.destinationViewController as! EventPhotoFullSize
if (segue.identifier == "eventphotofullsize") {
let cell = sender as! EventAlbumCustom
Dest.imageURL = cell.pic
}
}
我希望这可以帮到你