Drag Image

iPhone SDK Tips & Tricks


- (void)loadView
{
UIImageView *paperView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
paperView.image = [UIIamge imageNamed:@”paper.png”];
paperView.userInteractionEnabled = YES;

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
UITouch *touch = [touches anyObject];

if([touch view] == paperView)
{
paperView.center = [touch locationInView:self];
}
}