Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UITextField上的UITapGestureRecognizer在IOS 7.1中不再工作_Ios_Iphone_Objective C_Uitapgesturerecognizer_Ios7.1 - Fatal编程技术网

UITextField上的UITapGestureRecognizer在IOS 7.1中不再工作

UITextField上的UITapGestureRecognizer在IOS 7.1中不再工作,ios,iphone,objective-c,uitapgesturerecognizer,ios7.1,Ios,Iphone,Objective C,Uitapgesturerecognizer,Ios7.1,我在UITextField上附加了一个uitagesturerecognizer,以获得类似“下拉”的效果。当点击UITextField时,我会显示一个带有内容的uipover。这就像7.1之前的魅力一样-现在UITextField只是成为第一响应者,而手势识别器被完全忽略。尝试将delaysTouchedBegan设置为YES,但没有帮助。有帮助吗?实现UITextField的委托方法: - (BOOL)textFieldShouldBeginEditing:(UITextField *)te

我在
UITextField
上附加了一个
uitagesturerecognizer
,以获得类似“下拉”的效果。当点击
UITextField
时,我会显示一个带有内容的
uipover
。这就像7.1之前的魅力一样-现在
UITextField
只是成为第一响应者,而手势识别器被完全忽略。尝试将
delaysTouchedBegan
设置为YES,但没有帮助。有帮助吗?

实现
UITextField
的委托方法:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
      // Show popover here

      return NO;
}

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

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

   //Do what you need to do...

}


您可以将
文本视图
包装在
UIView
中,并在该视图上添加
UIAppgestureRecognitizer

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

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

然后设置您的TapPassive.delegate=self

我刚刚在另一个视图中包装了textview。但是需要禁用文本字段的用户交互。
textfield应该开始编辑:
delegate方法在文本字段已经是第一响应者时不会被调用。通过实现@JuroSheridan回答的手势识别器委托,它应该在所有情况下都能正常工作。我面临同样的问题?想知道原因。这应该是公认的答案。使用textViewShouldBeginEditing有一些问题。如果视图控制器中有多个UITextFields,则会随机调用所有UITextFields的TextViewShouldBeginEdit。