【发布时间】:2015-07-03 06:40:12
【问题描述】:
我正在尝试将相同的 UITapGestureRecognizer 添加到多个视图中
var tapGesture = UITapGestureRecognizer(target: self, action: "selectOptionsForRating:")
tapGesture.numberOfTapsRequired = 1
serviceLbl.addGestureRecognizer(tapGesture)
pickUpTimeLbl.addGestureRecognizer(tapGesture)
drivingLbl.addGestureRecognizer(tapGesture)
communicateLbl.addGestureRecognizer(tapGesture)
bikeConditionLbl.addGestureRecognizer(tapGesture)
dropOffLbl.addGestureRecognizer(tapGesture)
serviceLbl.tag = Service
pickUpTimeLbl.tag = PickUpTime
drivingLbl.tag = Driving
communicateLbl.tag = Communicate
bikeConditionLbl.tag = BikeCondition
dropOffLbl.tag = DropOff
}
func selectOptionsForRating(tapsender:UITapGestureRecognizer){
var sender = tapsender.view
if sender!.tag == Service {
println("tap gesture is working fine ")
}else if sender!.tag == PickUpTime {
println("tap gesture is working fine ")
}else if sender!.tag == Driving {
println("tap gesture is working fine ")
}else if sender!.tag == Communicate {
println("tap gesture is working fine ")
}else if sender!.tag == BikeCondition {
println("tap gesture is working fine ")
}else if sender!.tag == DropOff {
println("tap gesture is working fine ")
}
Recognizing multiple UILabels tap for UITapGestureRecogniser此链接向我展示了如何将相同的手势识别器添加到多个视图,但它不起作用..我不能将相同的手势识别器添加到多个视图吗?
【问题讨论】:
标签: ios swift uilabel uitapgesturerecognizer