首页 > UIImageView怎么设置点击事件ios,swift?

UIImageView怎么设置点击事件ios,swift?

let tapStepGestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("enterStepDetail"))
stepLogo.addGestureRecognizer(tapStepGestureRecognizer)

 func enterStepDetail(){
    print("step detail ok")
 }
//我现在的代码,但是下面的方法不执行。

userInteractionEnabled 默认是false,需要设置为true


//添加这行代码就可以了,意思是接收交互
stepLogo.userInteractionEnabled = true
【热门文章】
【热门文章】