我有2个标签和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'的时候点击输出,但是当我用3更改了第2行时,例如代码工作时我点击“测试”
答案 0 :(得分:0)
我通过添加更多taprecognizer(每个)来处理它