2011-08-05 7 views
0

私はサブクラス化したUITableViewCellをカスタム描画しています。そこには、ユーザーのやりとりを必要とするOpenGL ES 2.0コントロールがあります。コントロールを水平にドラッグすると、コントロールが応答しますが、垂直方向に移動するとすぐに、テーブルビューのビューポートが移動し始めます。どのようにしてこのインタラクションがUITableViewに行くのを止め、それをUITableViewCellの自分のUIViewに限定しますか?ユーザ対話の伝播をキャプチャして停止するiOS UITableViewCell

答えて

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]; 
} 
1

UITableViewでのユーザーのやりとりを防ぐことはできません。すべてのサブビューに影響するためです。
私はあなたがそれを使いたいメソッドにUITableViewインタラクションを送信しようとします。

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { 
    [MyClass myScrollDidStartMethod]; 
} 

または使用 - (無効)scrollViewDidScroll:(UIScrollViewの*)送信者を使用すると、スクロール方向を取得するために、送信者のcontentOffsetに取り組むことができるように(これについての詳細はthis postを参照)

+0

ありがとうございます。サブクラス化は必要ありません。 –

関連する問題