Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: touch point capture in UITableViewController

I want to capture x position of the touch point in UITableViewController. The most simply solution described in the web is UITapGestureRecognizer: enter link description here

But in this case, didSelectRowAtIndexPath are stopped.

How tu use both of the events, or how to get (NSIndexPath *)indexPath parameter inside singleTapGestureCaptured ?

Regards

[edit] I can't answer my question. The solution is:

NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:touchPoint]

like image 250
theWalker Avatar asked Dec 06 '25 12:12

theWalker


1 Answers

I doubt the OP is still waiting for an answer, but for the benefit of future searchers:

You can grab the touch event inside the cell, act, then either discard it, or pass it up the chain:

@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
like image 61
kwiqsilver Avatar answered Dec 09 '25 05:12

kwiqsilver