我UITableViewCell
UIPickerView
。我想抓住1个元素的录制事件(所以不是
pickerView(_:didSelectRow:inComponent:)
所做的)
这是我的班级:
class PickerTableViewCell: UITableViewCell {
@IBOutlet var pickerView:UIPickerView!
private var gestureRecognizer:UITapGestureRecognizer!
override func awakeFromNib() {
gestureRecognizer = UITapGestureRecognizer(target: self, action: "didTap:")
gestureRecognizer.cancelsTouchesInView = false
pickerView.addGestureRecognizer(gestureRecognizer)
}
func didTap(gestureRecognizer:UITapGestureRecognizer) {
print("tap")
}
override func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
正如其他回复中所建议的那样,我覆盖了UIGestureRecognizerDelegate
方法shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer
以返回true,但它没有帮助。
答案 0 :(得分:0)
我需要添加设置UITapGestureRecognizer
的委托。
gestureRecognizer.delegate = self
完成了这项工作,因为我已经超越了shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer
!