gpt4 book ai didi

swift - 无法识别的选择器发送到实例

转载 作者:行者123 更新时间:2023-11-30 12:13:57 24 4
gpt4 key购买 nike

我想这个问题很容易被归类为重复问题,但搜索后找不到答案。

在我的tableViewcellForRowAt

let chooseProfilePhotoPicker = ChooseProfilePhotoPicker(rootVC: self)
chooseProfilePhotoPicker.cropVC.delegate = self
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(chooseProfilePhotoPicker.iconImageViewTapped(_:)))
cell.iconImageView.addGestureRecognizer(tapGesture)

以及ChooseProfilePhotoPicker 类:

class ChooseProfilePhotoPicker: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

var rootController: UIViewController

init(rootController: UIViewController) {
self.rootController = rootController
}

func iconImageViewTapped(_ recognizer: UITapGestureRecognizer) {

var pickerController = UIImagePickerController()
pickerController.delegate = self
pickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary

rootController.present(myPickerController!, animated: true, completion: nil)
}
}

当我点击 iconImageView 时应用程序崩溃

最佳答案

如果操作应该在ChooseProfilePhotoPicker实例中运行,您必须相应地设置目标:

let tapGesture = UITapGestureRecognizer(target: chooseProfilePhotoPicker, action: #selector(chooseProfilePhotoPicker.iconImageViewTapped(_:)))

关于swift - 无法识别的选择器发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45659079/

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