Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

iPhone Programming - UIImageViews:Dragging multiple Images

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
2,180
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Feb 24, 2011

A Quick tutorial requested by LockerzSwagbucks(Channel Link Below).

In this tutorial I teach you how to enable multi-touch to drag 2 images around the screen at once.

Main Code:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];

if ([touch view] == image) {
image.center = location;
} else if ([touch view] == image2) {
image2.center = location;
}
[self ifCollided];
}

if (CGRectIntersectsRect(image.frame, collisionImage.frame) || CGRectIntersectsRect(image2.frame, collisionImage.frame))

LockerzSwagBucks: http://www.youtube.com/lockerzswagbucks

First Video: http://www.youtube.com/watch?v=H1wOlmwN94o

Link: http://developer.apple.com/devcenter/ios/index.action
Website: http://failcake.webs.com/
Twitter: http://twitter.com/failcakeapps
Channel: http://youtube.com/milmersxcode

Category:

Howto & Style

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (MilmersXcode)

  • Doesn't work :(

    anybody's succeeded? help please...

  • @inigo333 What are the problems you are encountering? I can help.

    Milmer.

  • Ya I did that but I have a different colide statement that I put in erry thong works drag and such but not multituch

  • @chasethemooseinc I don't know then mate. I am sorry. I have absolutely no idea how to do it. Multitouch is a tricky thing in my opinion. You could try adding [self setMultipleTouchEnabled:YES]; into the viewDidLoad method but I don't think that would work.

    If you do find out how to do it give me a ping. Other than that I am extremely sorry I can't help you :(

see all

All Comments (14)

Sign In or Sign Up now to post a comment!
  • Thank you very much, great tutorial!

  • thanx a lot !!!

  • @chasethemooseinc Yes it does matter. For 1 make sure you have another IF Statement for your 3rd image.

    2nd, Make sure you have the .centers named correctly for each if statement otherwise, the center of the same image will only be draggable. Below is some code to help you with 3 images.

    if ([touch view] == image) { image.center = location; } else if ([touch view] == image2) { image2.center = location; } else if ([touch view] == image3) { image3.center = location; }

  • @MilmersXcode Yes i have and i copied the code from you and i am using 3 images does tht mater

  • @chasethemooseinc Make sure you have checked the boxes in interface builder, Make sure you have got the if statements correct

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more