How To Draw line on touch event ?

Posted by AJPatel on Stack Overflow See other posts from Stack Overflow or by AJPatel
Published on 2011-01-12T13:50:16Z Indexed on 2011/01/12 13:54 UTC
Read the original article Hit count: 122

Hey i m beginner of objective C Please Help me

i make following code but not work.....

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *touch = [touches anyObject];
if ([touch view] == self.view) {

    CGPoint location = [touch locationInView:self.view];
    loc1 = location;
    CGContextMoveToPoint(context, location.x, location.y);
    NSLog(@"x:%d y:%d At Touch Begain", loc1.x, loc1.y);
}

} - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

{ UITouch *touch = [touches anyObject];

    if ([touch view] == self.view) 
{
    CGPoint location = [touch locationInView:self.view];
    CGContextMoveToPoint(context, loc1.x, loc1.y);
    NSLog(@"x:%d y:%d At Touch Move", loc1.x, loc1.y);
    CGContextAddLineToPoint(context, location.x, location.y);
    NSLog(@"x:%d y:%d", location.x, location.y);
}

}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c