サブクラス化した UITableViewCell をカスタム描画しています。そこには、ユーザーの操作が必要な OpenGL ES 2.0 コントロールがあります... 水平方向にドラッグを開始すると、コントロールは応答しますが、垂直方向に移動するとすぐに、テーブル ビューのビューポートを移動し始めます。このインタラクションが UITableView に行くのを止めて、UITableViewCell の自分の UIView に制限するにはどうすればよいですか?
1932 次
2 に答える
1
UITableView をサブクラス化し、次のメソッドをオーバーライドすることができます
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
// if user tapped on your custom view, disable scroll
self.scrollEnabled = NO;
// end if
[super touchesBegan:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
self.scrollEnabled = YES;
[super touchesEnded:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
self.scrollEnabled = YES;
[super touchesCancelled:touches withEvent:event];
}
于 2011-08-07T13:43:32.360 に答える
1
すべてのサブビューに影響するため、UITableView でのユーザーの操作を防ぐことはできないと思います。
UITableView インタラクションを、使用したいメソッドに送信してみます。
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[MyClass myScrollDidStartMethod];
}
または - (void)scrollViewDidScroll:(UIScrollView *)sender を使用して、送信者の contentOffset を操作してスクロール方向を取得できるようにします (詳細については、この投稿を参照してください)。
于 2011-08-07T13:32:49.187 に答える