Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6616293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:33:56+00:00 2026-05-25T20:33:56+00:00

I am working on trying to get multiple UIImageViews to move when they are

  • 0

I am working on trying to get multiple UIImageViews to move when they are dragged. I was originally putting all the movement under TouchesBegan. However, when I drag a single object, they all disappear and only the one I am dragging moves.

How can I have each image dragged own its own terms(I drag the first image, only the first image moves etc.)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:33:57+00:00Added an answer on May 25, 2026 at 8:33 pm

    I’m not sure if this is what you’re looking for but I worked on this a while ago, so hopefully it’s useful.

    Just make sure you set up 7 UIImageViews in the XIB File, link them and you’ll be good to go.

    @synthesize img1, img2, img3, img4, img5, img6, magnet;
    
    -(void) checkInsertion {
        if (CGRectContainsRect(img2.frame, img1.frame)) {img1.center = img2.center;}
        if (CGRectContainsRect(img4.frame, img3.frame)) {img3.center = img4.center;}
        if (CGRectContainsRect(img6.frame, img5.frame)) {img5.center = img6.center;}
    
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.2];
        if (CGRectIntersectsRect(magnet.frame, img1.frame)) {img1.center = magnet.center;}
        if (CGRectIntersectsRect(magnet.frame, img2.frame)) {img2.center = magnet.center;}
        if (CGRectIntersectsRect(magnet.frame, img3.frame)) {img3.center = magnet.center;}
        if (CGRectIntersectsRect(magnet.frame, img4.frame)) {img4.center = magnet.center;}
        if (CGRectIntersectsRect(magnet.frame, img5.frame)) {img5.center = magnet.center;}
        if (CGRectIntersectsRect(magnet.frame, img6.frame)) {img6.center = magnet.center;}
        [UIView commitAnimations];
    
    }
    
    -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch * touch = [[event allTouches] anyObject];
        CGPoint touchLoc = [touch locationInView:touch.view];
    
        if (CGRectContainsPoint(img1.frame, touchLoc)) {img1.center = touchLoc;}
        if (CGRectContainsPoint(img3.frame, touchLoc)) {img3.center = touchLoc;}
        if (CGRectContainsPoint(img5.frame, touchLoc)) {img5.center = touchLoc;}
    
        if (CGRectContainsPoint(magnet.frame, touchLoc)) {magnet.center = touchLoc;}
    
        [self checkInsertion];
    }
    
    -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        [self touchesBegan:touches withEvent:event];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a multiple upload library working for my Codeigniter based
I have this code, but can't get it all working. I am trying to
I'm trying to get a .toggleClass working on a form that I have multiple
im trying to get role provider working in multiple environments and hitting a wall
I'm stuck trying to get multiple textures working in OpenGL using Haskell. I've been
Whilst trying to get our app working in Firefox (I'm a big proponent of
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
Im trying to get debugging working without an app.config. I have the following code:
Im trying to get a form working in Internet Explorer. I see that when
I'm trying to get some code working that a previous developer has written. Yep,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.