私は私のtableViewCellに画像を持っていて、それをクリックすると(別のUIView)ポップアップが表示されます。私はポップアップに渡される画像のために私のtableviewcell上の画像をクリックしたいと思います。ポップアップを設定する方法は次のとおりです。 cellForItemAtIndexPathでtableviewcellのインデックスパスを送信
@IBAction func PopUpClicked(_ sender: Any) -> Void {
self.transparentBackground = UIView(frame: UIScreen.main.bounds)
self.transparentBackground.backgroundColor = UIColor(white: 0.0, alpha: 0.8)
UIApplication.shared.keyWindow!.addSubview(self.transparentBackground)
self.opaqueView = self.setupOpaqueView()
self.transparentBackground.addSubview(opaqueView)
UIApplication.shared.keyWindow!.bringSubview(toFront: self.transparentBackground)
self.view.bringSubview(toFront: transparentBackground)
}
func setupOpaqueView() -> UIView{
let mainView = UIView(frame: CGRect(x: 16, y: 132, width: Int(UIScreen.main.bounds.width-32), height: 403))
mainView.backgroundColor = UIColor(red:0.23, green:0.73, blue:1.00, alpha:1.0)
mainView.layer.cornerRadius = 6
let OKbutton = UIButton(frame: CGRect(x: 151, y: Int(mainView.frame.height-60), width: 40, height: 40))
OKbutton.setImage(UIImage.init(named: "AddOn"), for: .normal)
OKbutton.layer.borderColor = UIColor.white.cgColor
OKbutton.layer.borderWidth = 2
OKbutton.layer.cornerRadius = 20
self.imageView = UIImageView(frame: CGRect(x: 29, y: 18, width: 274, height: 310))
self.imageView.layer.backgroundColor = UIColor.white.cgColor
mainView.addSubview(OKbutton)
mainView.addSubview(self.imageView)
OKbutton.addTarget(self, action: #selector(ThirdWheelViewController.handleOKButtonTapped(_:)), for: .touchUpInside)
return mainView
}
func handleOKButtonTapped(_ sender: UIButton){
removeAnimate()
}
func removeAnimate()
{
UIView.animate(withDuration: 0.25, animations: {
self.transparentBackground.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
self.transparentBackground.alpha = 0.0;
}, completion:{(finished : Bool) in
if (finished)
{
self.transparentBackground.removeFromSuperview()
}
});
}
カントあなたにこの保存された画像変数から読み取る
self.opaqueView = self.setupOpaqueView()
を使用して作成PopUpClicked
機能をユーザーがクリックするだけで'self.imageView.image = cellImageView.image'を割り当てます。ここで' cellImageView'はあなたのセルの画像ビューですか? – Paulw11