[英]UILongPressGestureRecognizer and UITextField don't work together
I have a UIViewController with a LongPressGesturerecognizer attached. 我有一个附有LongPressGesturerecognizer的UIViewController。 There is also a UITextField in the view controllers view.
视图控制器视图中还有一个UITextField。
If I tap on the UITextField, the Gesturerecognizer catches the long press. 如果我点击UITextField,Gesturerecognizer会抓住长按。 Copy, paste, cursor oving is not possible.
无法复制,粘贴,光标。
I would like to have the Gesturerecognizer be active anywhere in the view except the UITextField, where I would like the default OS behaviour like copy, paste, move the cursor etc. 我想让Gesturerecognizer在视图中的任何地方都处于活动状态,除了UITextField,我想要默认的操作系统行为,如复制,粘贴,移动光标等。
Is that possible? 那可能吗? Can I somehow tell the gesture recognizer to forward the gesture to the UITextFields default?
我可以以某种方式告诉手势识别器将手势转发到UITextFields默认值吗?
You have to set a delegate to your UILongPressGestureRecognizer
and implement the gestureRecognizer:shouldReceiveTouch:
delegate method like this: 您必须将
UILongPressGestureRecognizer
设置为UILongPressGestureRecognizer
并实现gestureRecognizer:shouldReceiveTouch:
委托方法,如下所示:
- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return touch.view != self.textField;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.