userInteractionEnabled

userInteractionEnabled

本文介绍了UIImageview上的UITapGesture无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying too make UIImage as button using UITapGesture.

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)
}

当我跑步并点击图像时,什么也没发生.谁能帮我.

When I run and tap the image, nothing happened. Can anyone help me please.

推荐答案

在图像上添加 userInteractionEnabled true并尝试

add userInteractionEnabled true on your image and try

brandMenuContactImage.userInteractionEnabled  = true

objective-C

 brandMenuContactImage.userInteractionEnabled  = YES;

更新

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

这篇关于UIImageview上的UITapGesture无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 18:24