How to add images while moving finger across UIView?

Posted by Luke Irvin on Stack Overflow See other posts from Stack Overflow or by Luke Irvin
Published on 2012-11-06T04:00:24Z Indexed on 2012/11/06 5:00 UTC
Read the original article Hit count: 239

I am having issues adding an image across a view while moving finger across the screen.

Currently it is adding the image multiple times but squeezing them too close together and not really following my touch.

Here is what I am trying:

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

    UITouch * touch = [touches anyObject];
    touchPoint = [touch locationInView:imageView];

    if (touchPoint.x > 0 && touchPoint.y > 0) {

       _aImageView = [[UIImageView alloc] initWithImage:aImage];
       _aImageView.multipleTouchEnabled = YES;
       _aImageView.userInteractionEnabled = YES;
      [_aImageView setFrame:CGRectMake(touchPoint.x, touchPoint.y, 80.0, 80.0)];
      [imageView addSubview:_aImageView];
      [_aImageView release];
    }
}

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

    [self touchesBegan:touches withEvent:event];
}

Any suggestions is much appreciated.

EDIT:

What I want:

After taking or choosing an image, the user can then select another image from a list. I want the user to touch and move their finger across the view and the selected image will appear where they drag their finger, without overlapping, in each location.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about uiview