本文介绍了在UITextView中成功滑动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人能够在UITableView上实现成功的滑动手势?默认情况下,由于控件的滚动特性,这是不可能的。我已经尝试了子类化UITextView并在实例方法中实现了滑动功能,但没有骰子。
Has anyone been able to implement a successful swipe gesture on a UITableView? By default this is not possible due to the scrolling nature of the control. I've tried subclassing UITextView and implementing the swipe function in the instance methods, but no dice.
我的UITextView已禁用滚动 - 除非有另一种方法来实现多行文本?
My UITextView has scrolling disabled - Unless there is another way to implement multiline text?
我应该说的是输入多行文字[/编辑]
What I should say is input multiline text[/Edit]
推荐答案
我发现,更好的解决方案是简单地将触摸传递回superview:
An even better solution, I have found, is to simply pass touches back to the superview:
@interface SwipeableTextView : UITextView {
}
@end
@implementation SwipeableTextView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self.superview touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesMoved:touches withEvent:event];
[self.superview touchesMoved:touches withEvent:event];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
[self.superview touchesEnded:touches withEvent:event];
}
@end
这篇关于在UITextView中成功滑动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!