Unable to get tap event in scrolling view or scrollable table view?
hmm... Really a bad situation.. by the way here is the solution :)
Put this in viewDidLoad method :
(YOUR_SCROLL_VIEW may be UIScrollView or scrollable UITableView)
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)];
[YOUR_SCROLL_VIEW addGestureRecognizer:singleTap];
and you will get the touches with :
- (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture
{
CGPoint touchPoint=[gesture locationInView:YOUR_SCROLL_VIEW];
NSLog(@"Touch point coordinates are : %f - %f", touchPoint.x , touchPoint.y );
}
this worked for me, hope this helps to save your time!
it works very fine, but after capture this event its no more didSelectRowAtIndexPath events. How to get indexPath in this case?
ReplyDeletein viewDidLoad method, Please add :
ReplyDeletesingleTap.cancelsTouchesInView = NO;
//(where singleTap is UITapGestureRecognizer instance )
below to these two lines.
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)];
[YOUR_SCROLLABLE_TABLE_VIEW addGestureRecognizer:singleTap];
It must do the trick. If any more issues, Feel free to disucuss!