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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Why to use UITapGestureRecognizer
, better to use UITextFieldDelegate
methods
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
//Do what you need to do...
}
OR
You can wrap up your textView
in a UIView
and add the UITapGestureRecognizer
on that view.
回答2:
Implement the delegate method for your tap gesture
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
Then set yourTapGesture.delegate = self;
回答3:
Implement the delegate method of the UITextField
:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
// Show popover here
return NO;
}