gpt4 book ai didi

ios - 如果我在同一 View 上有两个 ImageView ,如何区分哪个 UIImagePickerController 调用 func didCancel?

转载 作者:行者123 更新时间:2023-11-28 11:33:48 26 4
gpt4 key购买 nike

我在同一 View 上有两个 UIImageView(leftImageViewrightImageView)。我想知道哪个 UIImagePickerController 正在调用 imagePickerControllerDidCancel。是 leftImageView 还是右边那个?

这里是选择器按钮选择左侧或右侧图像的开关。

switch sender.tag {
// left image
case 0:
self.imageView = leftImage
default:
self.imageView = rightImage
}

下面的函数能够知道哪个 ImageView 正在调用它。但是 didCancel 函数不会:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[.originalImage] as? UIImage {
self.imageView.image = image
}
picker.dismiss(animated: true, completion: nil)
}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
// the rightImageView or the leftImageView calling the cancel?

if (rightImageView){
// print("the right image ")
}

picker.dismiss(animated: true, completion: nil)
}

最佳答案

您已经拥有所需的信息。检查 self.imageView:

if self.imageView === leftImageView {
// it's the left image view
} else {
// it's the right image view
}

关于ios - 如果我在同一 View 上有两个 ImageView ,如何区分哪个 UIImagePickerController 调用 func didCancel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56138531/

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