I just do a sample to check the pan gesture.
The pan gesture is detecting and working fine.
But whenever i give a secondPoint in the pan gesture like CGPoint secondPoint = [sender locationOfTouch:1 inView:self.imageView];
it is crashing.
The console is giving the message
*** Terminating app due to uncaught exception 'NSRangeException', reason: '-[UIPanGestureRecognizer locationOfTouch:inView:]: index (1) beyond bounds (1).'
When I use panGestureRecognizer.maximumNumberOfTouches = 1;
panGestureRecognizer.minimumNumberOfTouches =1; still it is crashing.
When I use panGestureRecognizer.maximumNumberOfTouches = 2;
panGestureRecognizer.minimumNumberOfTouches = 2;
then it is not entering into the
- (void)panGestureHandler:(UIPanGestureRecognizer *)sender method.
Can anyone please guide me where im going wrong.
Thanks in advance.Hoping for your help.
I tried in this way.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGestureHandler:)];
panGestureRecognizer.maximumNumberOfTouches = 2;
[self.imageView addGestureRecognizer:panGestureRecognizer];
}
- (void)panGestureHandler:(UIPanGestureRecognizer *)sender
{
if ([sender state] == UIGestureRecognizerStateBegan )
{
CGPoint firstPoint = [sender locationOfTouch:0 inView:self.imageView];
CGPoint secondPoint = [sender locationOfTouch:1 inView:self.imageView];
}
else if ([sender state] ==UIGestureRecognizerStateEnded )
{
}
}