UITextField上的UITapGestureRecognizer不再适用于IOS 7.1

时间:2014-03-11 13:03:37

标签: ios iphone objective-c uitapgesturerecognizer ios7.1

我有一个UITapGestureRecognizer附加到UITextField以获得“下拉”效果。点击UITextField后,我会在内容中显示UIPopover。这就像一个魅力前7.1 - 现在UITextField只是成为第一响应者,并且完全忽略了手势识别器。尝试将delaysTouchedBegan设置为YES,但它没有帮助。任何帮助?

3 个答案:

答案 0 :(得分:16)

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

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

   //Do what you need to do...

}

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

答案 1 :(得分:8)

为您的点按手势实施委托方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
   return YES;
}

然后设置yourTapGesture.delegate = self;

答案 2 :(得分:2)

实施UITextField

的委托方法
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
      // Show popover here

      return NO;
}