I would like the user to be able to press and drag one image (ex: image1.png) and place it over another (ex: image2.png). When the user releases, a third image (ex: image3.png) is added to the screen. How could I go about doing that in xcode?

2

There are 2 best solutions below

0
Giuseppe Mosca On BEST ANSWER

It's not so easy to do what you want, you have to start to see this touches tutorial from Apple Developer program

0
Sven Vietense On

here is a code sample for the image moving:

    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [[event allTouches] anyObject];
        CGPoint location = [touch locationInView:self.view];
        if (CGRectContainsPoint([image1 frame], location)) {
        images.center = location;

        if (CGRectContainsPoint([image1 frame], [image2 frame]) {
           //place your code when image1 = images2       
           [self.view addSubview:image3];
           }
        }
    }

i think something like this could work