UITapGestureRecognizer on UITextField no longer works in IOS 7.1

匿名 (未验证) 提交于 2019-12-03 08:48:34

问题:

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; } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!