2012-01-21 13 views
3

におけるタッチポイントのキャプチャ。 ウェブで説明した最も単純ソリューションはUITapGestureRecognizerです:enter link description hereiPhone:私は<strong>のUITableViewController</strong>に<strong>タッチ</strong>ポイントの<strong>のx位置</strong>をキャプチャしたいのUITableViewController

しかし、この場合には、didSelectRowAtIndexPathが停止されています。 TUがイベントの両方を使用する方法、または(NSIndexPath *)indexPathパラメータを取得する方法を

をsingleTapGestureCaptured?

よろしく

[編集] 私は私の質問に答えることはできません。 解決策は以下のとおりです。

NSIndexPath * indexPath = [self.tableView indexPathForRowAtPoint:タッチポイント]

答えて

0

あなたはタッチイベントのテーブルビューの取り扱いをめちゃくちゃにすることなく、ジェスチャー認識を追加することはできません。

あなたは達成しようとしていることを正確には言わないので、代替案を推奨することはできません。タッチイベントをキャプチャすることに関連するものは複雑になるでしょう:レスポンダーチェーンは複雑です。

簡単な方法は、

2

...子クラスに過負荷didSelectRowAtIndexPathも、あなたがスーパーを呼び出す前に、やりたいように思えるでしょう、私はOPはまだ答えを待っているが、将来サーチャーの利益のためにされた疑い:

あなたは、細胞内でタッチイベントをつかむことができ、行為、それを破棄、またはチェーンをそれを渡す次のいずれか

@interface MyCell : UITableViewCell 
// ... 
@end 

@implementation MyCell 
// ... 

- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event 
{ 
    UITouch* touch = [[event allTouches] anyObject]; 
    CGPoint someLocation = [touch locationInView: someView]; 
    CGPoint otherLocation = [touch locationInView: otherView]; 
    if ([someView pointInside: someLocation: withEvent: event]) 
    { 
     // The touch was inside someView. Do some stuff, 
     // but don't invoke tableView:didSelectRowAtIndexPath: on the delegate. 
    } 
    else if ([otherView pointInside: otherLocation: withEvent: event]) 
    { 
     // The touch was inside otherView. Do other stuff. 

     // Send the touch on for processing, and tableView:didSelectRowAtIndexPath: handling. 
     [super touchesBegan: touches withEvent: event]; 
    } 
    else 
    { 
     // Send the touch on for processing, and tableView:didSelectRowAtIndexPath: handling. 
     [super touchesBegan: touches withEvent: event]; 
    } 
} 
@end 
関連する問題

 関連する問題