I am using Longpress gesture on UIImageview. UIimageview is added in UIscrollview as a subview and scroll view is added as a subview in UIview.I am trying to draw a line on image from that point where user performed the long press gesture to any other random point.random point will set programatically.Currently my long press gesture location is different on screen and point which i am getting is different dont know why ? my code is
- (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender
{
NSLog(@"Long Press Gesture");
CGPoint location = [sender locationInView:self.imageView];
UIColor * linearcolor=[UIColor whiteColor];
///////// code //////
////// code end /////
UIGraphicsBeginImageContext(originalImage.size);
[originalImage drawAtPoint:CGPointMake(0,0)];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 5.0);
CGPoint * location2;
location2->x=0.0;
location2->y=0.0;
CGContextMoveToPoint(context, location.x, location.y);
CGContextAddLineToPoint(context,location2->x,location2->y);
CGContextSetStrokeColorWithColor(context, [linearcolor CGColor]);
CGContextStrokePath(context);
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
imageView.image=newImage;
}