gpt4 book ai didi

ios - UIImageview 上的 UITapGesture 不工作

转载 作者:搜寻专家 更新时间:2023-11-01 06:40:11 25 4
gpt4 key购买 nike

我也在尝试使用 UITapGesture 将 UIImage 设为按钮。

let contactSegueIdentifier = "showContactSegue"

override func viewDidLoad() {
initTapGestureRec()
}

func initTapGestureRec() {
let tapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("recognizeTapGesture:"))
brandMenuContactImage.addGestureRecognizer(tapGesture)
}

func recognizeTapGesture(sender: UIGestureRecognizer) {
self.performSegueWithIdentifier(contactSegueIdentifier, sender: self)
}

当我运行并点击图像时,没有任何反应。谁能帮帮我。

最佳答案

在你的图像上添加 userInteractionEnabled true 并尝试

brandMenuContactImage.userInteractionEnabled  = true

objective-C

 brandMenuContactImage.userInteractionEnabled  = YES;

更新

override func viewDidLoad() {
brandMenuContactImage.userInteractionEnabled = true
initTapGestureRec()
}

关于ios - UIImageview 上的 UITapGesture 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36495751/

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