Objective c 向前触摸而不是双击UITextView
我有一个Objective c 向前触摸而不是双击UITextView,objective-c,ios,uitextview,uigesturerecognizer,uiresponder,Objective C,Ios,Uitextview,Uigesturerecognizer,Uiresponder,我有一个UITextView,除此之外,我还有多个UIView。ui视图上的任何触摸动作都可以关联到相应的i动作。在我的场景中,双击手势需要关联到UIView的iAction,除此之外的任何其他触摸都需要转发到底层的UITextView 执行上述场景的代码块 UITextView *textView = [[UITextView alloc] init]; UIView *subview = [[UIView alloc] init]; UITapGestureRecognizer *dou
UITextView
,除此之外,我还有多个UIView
。ui视图
上的任何触摸动作都可以关联到相应的i动作
。在我的场景中,双击手势需要关联到UIView
的iAction
,除此之外的任何其他触摸都需要转发到底层的UITextView
执行上述场景的代码块
UITextView *textView = [[UITextView alloc] init];
UIView *subview = [[UIView alloc] init];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected:)];
doubleTap.numberOfTapsRequired = 2;
[subview addGestureRecognizer:doubleTap];
[textView addSubview: subview];
我尝试了以下解决方案
使用hitTest,我无法在UIView中捕获双击手势,该手势位于UITextView
将UITextView
中的uitextTouch
设置从touchBegind:withEvent:
转发到UITextView
不会给出预期的默认行为UITextView
是否有其他解决方案可用于解决此情况
提前感谢。子视图是不必要的,请将其删除,然后更换:
[subview addGestureRecognizer:doubleTap];
与:
现在,您应该在tapDetected:method中获取事件
要确保未更改UITextView行为,请使用以下方法:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
或
这可以通过以下方式实现:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch