gpt4 book ai didi

ios - 将 uiimage 图像 url 数据传递到另一个 View

转载 作者:行者123 更新时间:2023-11-30 13:27:36 25 4
gpt4 key购买 nike

我在主 VC 中有一个 Collection View ,需要将图像的 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 和 url

最佳答案

您找不到在单元格中声明的属性,因为在 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
}
}

希望对你有帮助

关于ios - 将 uiimage 图像 url 数据传递到另一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36971194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com