【发布时间】:2009-03-25 14:00:15
【问题描述】:
我有一个包含 UITextView(不可编辑)的 UIScrollView。 我无法让 UIScrollView 获取触摸事件, UITextView 似乎获取并保留它们。知道如何让 UIScrollView 获取触摸事件吗?
我希望 UITextView 仍然可以垂直滚动(我的 UIScrollView 只能水平滚动)。
【问题讨论】:
标签: iphone objective-c
我有一个包含 UITextView(不可编辑)的 UIScrollView。 我无法让 UIScrollView 获取触摸事件, UITextView 似乎获取并保留它们。知道如何让 UIScrollView 获取触摸事件吗?
我希望 UITextView 仍然可以垂直滚动(我的 UIScrollView 只能水平滚动)。
【问题讨论】:
标签: iphone objective-c
在您的 UITextView 子类中,执行以下操作:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.nextResponder touchesBegan:touches withEvent:event];
}
如果您也希望UITextView 处理触摸,那么我相信您可以这样做:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.nextResponder touchesBegan:touches withEvent:event];
[super touchesBegan:touches withEvent:event];
}
但它可能会导致非常奇怪的行为。
【讨论】: