[英]Swift UITapGestureRecognizer
For some reason, I can't get my gesture recognizer to work. 由于某些原因,我无法使手势识别器正常工作。 The following line of code is executed in the
viewDidLoad
method: 下面的代码行在
viewDidLoad
方法中执行:
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.segmentTapped(sender:))))
The following is the method associated with the gesture: 以下是与手势关联的方法:
func segmentTapped(sender: UITapGestureRecognizer) {
print("called")
}
When the code is executed, "called" does not print in the console when the view is tapped. 执行代码后,点击视图时,不会在控制台中打印“被调用”。 Gesture recognizers have always worked for me in the past, and I am confused as to what is going wrong.
过去,手势识别器一直为我工作,而我对发生的问题感到困惑。
Thanks you everyone who tried to help! 谢谢所有尝试提供帮助的人! The solution to this problem was quite simple.
解决这个问题的方法非常简单。 I simply deleted the app, reinstalled it, and the tap gesture worked as intended.
我只是删除了该应用程序,然后重新安装它,然后轻按手势即可正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.