views:

255

answers:

2

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { touchStartTime = [event timestamp]; }

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
    NSTimeInterval touchTimeDuration = [event timestamp] - touchStartTime; 
}

touchStartTime is defined at class level.

Any idea why this won't recognise the touch events?

+1  A: 

Personally, from my experience with the UITableView, I don't think that you can use the touch events.

You may have to look into other ways of dealing with this. For example, try using the selection as a helper?

Ardman
A: 

Yes, this is possible to do. I setup a test project with a custom UITableViewCell subclass and defined the methods in the same way that you have, adding a log to the touchesEnded to print the touchTimeDuration. I ran it in the simulator and it seems to work for me.

How are you determining if your code is recognizing the events?

Mike Cugini
Hey Mike, cheers for the reply.The code works fine, at the bottom layer of the XIB file (i.e. the UIImageView).I can touch and hold, when I lift my finger off of the UIImageView the NSLog states the time I held my finger on the screen. But won't initialise on the UITableViewCell (which is a custom cell, if that makes any difference).
Neurofluxation