gpt4 book ai didi

ios - 无法让 UIImageView 在 prepareForSegue 中发送

转载 作者:行者123 更新时间:2023-11-29 01:18:41 25 4
gpt4 key购买 nike

我正在尝试将图像从一个 View 传递到另一个 View ,但是当我运行下面的代码时,它一直在显示“进入此处”的位置输入。我该如何解决这个问题?

@IBOutlet weak var feedImage: UIImageView!

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let myCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! questionCell

//other code here ...

myCell.feedImage.tag = indexPath.row
print(myCell.feedImage.tag)

let tapGestureRecognizer = UITapGestureRecognizer(target:self, action:Selector("imageTapped:"))
myCell.feedImage.userInteractionEnabled = true
myCell.feedImage.addGestureRecognizer(tapGestureRecognizer)
}

func imageTapped(img: AnyObject)
{

performSegueWithIdentifier("questionToFullScreen", sender: self)
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

if segue.identifier == "questionToFullScreen" {
guard let feedImage = sender as? UIImageView else {
//ENTERING HERE
return }
guard let destinationViewController = segue.destinationViewController as? fullScreenImageViewController else { return }

//send the image to the next view
destinationViewController.image = resultsArray[feedImage.tag].imageFile
}
}

最佳答案

  1. 更改“img: AnyObject” --> “tap: UITapGestureRecognizer”
  2. 更改“发件人:自己”-->“发件人:tap.view”

    func imageTapped(tap: UITapGestureRecognizer) {

    performSegueWithIdentifier("questionToFullScreen", sender: tap.view)
    }

关于ios - 无法让 UIImageView 在 prepareForSegue 中发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34851260/

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