Iphone 如何为UITextView启用滑动手势

Iphone 如何为UITextView启用滑动手势,iphone,ipad,gesture-recognition,Iphone,Ipad,Gesture Recognition,如何为UITextView启用滑动手势识别 这是我的代码,附加到它的事件没有触发。它适用于水龙头,但不适用于刷卡 // Add swipe support for easy textview content clean up UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(eraseTextWithSwipe:)]; [targetCo

如何为UITextView启用滑动手势识别

这是我的代码,附加到它的事件没有触发。它适用于水龙头,但不适用于刷卡

// Add swipe support for easy textview content clean up
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(eraseTextWithSwipe:)];
[targetContent addGestureRecognizer:swipe];
[swipe release];

我该怎么做呢?

我找到了一个适合我的解决方案

您需要设置委托(参考上面的代码)

然后,您需要添加一个代理来跟踪多个手势,这将能够跟踪滑动和滚动

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGesture
{
    yourTextbox.scrollEnabled = NO;
    return YES;
}

在回调函数中重新启用滚动(在上面的示例中,使用擦除文本擦除)

谢谢。你的解决方案有效。我只需要设置委托并在提到的委托方法中返回YES。
如果不是出于可用性原因,您不必禁用UITextView上的滚动功能。

我不确定此问题中的任何建议是否有帮助;里面没有公认的答案。谢谢你的评论,但那不适用,我已经看过了。这项技术不是苹果在iPhone4.x中推荐的。
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGesture
{
    yourTextbox.scrollEnabled = NO;
    return YES;
}