Thursday, 12 December 2013

Applying touch events to UIScrollview

How can I detect touch points in my UIScrollView ? The touches delegate methods are not working.


Ans:

For this we need to set up a tap gesture.

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)];

[scrollView addGestureRecognizer:singleTap];   
 

and you will get the touches in:

- (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture
  {

    CGPoint touchPoint=[gesture locationInView:scrollView];
  }

No comments:

Post a Comment