图像视图无法识别我的点击手势

Image view not recognizing my tap gesture

我正在尝试从图像中呈现 UIImagePickerController,但它无法正常工作。我启用了用户交互,但似乎仍然无法正常工作。

let cameraIconImageView: UIImageView = {
    let image = UIImageView()
    image.image = UIImage(named: "camera_icon")?.withRenderingMode(.alwaysTemplate)
    image.tintColor = UIColor(r: 255, g: 122, b: 124, a: 1 )
    image.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleSelectProfileImage)))
    image.layer.borderWidth = 2
    image.layer.borderColor = UIColor(r: 255, g: 122, b: 124, a: 1 ).cgColor
    image.layer.cornerRadius = 20
    image.isUserInteractionEnabled = true
    image.clipsToBounds = true
    image.translatesAutoresizingMaskIntoConstraints = false
    return image
}()

@objc func handleSelectProfileImage() {
    let picker = UIImagePickerController()
    present(picker, animated: true, completion: nil)
    print(123)

    picker.delegate = self
    picker.allowsEditing = true

    present(picker, animated: true, completion: nil)
}
lazy var cameraIconImageView: UIImageView = {

let image = UIImageView()
image.image = UIImage(named: "camera_icon")?.withRenderingMode(.alwaysTemplate)
image.tintColor = UIColor(r: 255, g: 122, b: 124, a: 1 )
image.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleSelectProfileImage)))
image.layer.borderWidth = 2
image.layer.borderColor = UIColor(r: 255, g: 122, b: 124, a: 1 ).cgColor
image.layer.cornerRadius = 20
image.isUserInteractionEnabled = true
image.clipsToBounds = true
image.translatesAutoresizingMaskIntoConstraints = false
return image

}()

在 Imageview 初始化中使用延迟。