我已经下载了一组用户照片从firebase和查看它作为收集视图(Instagram的样子) 但即时通讯尝试放大照片点击另一个视图控制器使用赛格,但其不工作。 我的代码有什么想法:从收集视图控制器迅速传递图像到另一个视图控制器
class ProfileViewController: UIViewController{
var photoThumbnail: UIImage!
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collection_cell", for: indexPath) as! ProfileCollectionViewCell
cell.imageCollection.downloadImage2(from: currPosts[indexPath.row].photoUrl)
cell.imageCollection.image = photoThumbnail
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
performSegue(withIdentifier: "photoViewSegue", sender: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
var destViewController : EnlargePhotoViewController = segue.destination as! EnlargePhotoViewController
destViewController.labelText = "test" //**** this works
destViewController.myImage = photoThumbnail //**** this doesnt work
}
}
和收集观察室是:
class ProfileCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imageCollection: UIImageView!
}
最后目标的viewController:
class EnlargePhotoViewController: UIViewController {
@IBOutlet weak var myLabel: UILabel!
@IBOutlet weak var enlargedPhoto: UIImageView!
var labelText = String()
var myImage: UIImage!
override func viewDidLoad() {
super.viewDidLoad()
myLabel.text = labelText
enlargedPhoto.image = myImage
}
}
*它不是完整的代码,但我分享最重要的线 –
它很难知道该如何回答这个问题,没有看到所有的代码,在提取物提供的变量photoThumbnail从未设置始终为零。 – user863238