我有两个标签和uiimage,启用了用户交互,并通过以下代码添加了一个识别器:
let tapOnImagesOrLabels = UITapGestureRecognizer(target: self, action: #selector(login.logInTapped(_:)))
/* Line 1 */ test2.addGestureRecognizer(tapOnImagesOrLabels)
/* Line 2 */ test.addGestureRecognizer(tapOnImagesOrLabels)
/* Line 3 */ registerBtnLabel.addGestureRecognizer(tapOnImagesOrLabels)
test2.isUserInteractionEnabled = true
test.isUserInteractionEnabled = true
registerBtnLabel.isUserInteractionEnabled = true
//...
@IBAction func logInTapped(_ sender: Any) {
print("clicked")
}我只有在添加了最后一个识别器时才会得到打印输出,例如,在本例中,当我单击“RegisterBtnLabel”时,输出会被单击,但当我将第2行更改为3时,例如,当我单击“test”时,代码会正常工作。
发布于 2016-12-23 22:04:20
我通过添加更多的点击识别器来处理它(对于每一个)
https://stackoverflow.com/questions/41302458
复制相似问题