UITextField上的UITapGestureRecognizer在IOS 7.1中不再起作用

问题描述:

我在UITextField上附加了UITapGestureRecognizer,以获得类似下拉"的效果.轻按UITextField时,将显示包含内容的UIPopover.就像7.1之前的魅惑一样工作-现在UITextField成为第一响应者,而手势识别器完全被忽略了.尝试将delaysTouchedBegan设置为YES,但没有帮助.有帮助吗?

I have a UITapGestureRecognizer attached to a UITextField to get a "drop down" like effect. When the UITextField is tapped, I present a UIPopover with the content. This worked like a charm pre 7.1 - Now the UITextField just becomes first responder, and the gesturerecognizer is totally ignored. Tried setting delaysTouchedBegan to YES but it didn't help.Any help?

为什么要使用UITapGestureRecognizer,更好地使用UITextFieldDelegate方法

Why to use UITapGestureRecognizer, better to use UITextFieldDelegate methods

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{

   //Do what you need to do...

}

OR

您可以将textView包裹在UIView中,然后在该视图上添加UITapGestureRecognizer.

You can wrap up your textView in a UIView and add the UITapGestureRecognizer on that view.