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

  • SEARCH
  • Home
  • 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 9222267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:47:49+00:00 2026-06-18T03:47:49+00:00

I want to put two UIImageViews in my app that can be moved. When

  • 0

I want to put two UIImageViews in my app that can be moved. When one image comes in contact with the other, it triggers an action, and then puts both images back in their original places. Any suggestions for this?

I am using

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

UITouch *touch = [touches anyObject];

// If the touch was in the placardView, move the placardView to its location
if ([touch view] == resultImage) {
    CGPoint location = [touch locationInView:self.tabBarController.view];
    resultImage.center = location;

    return;
}
}

This allows resultImage to freely move around. I simply need to know how to detect when any part of it touches the other image (which is stationary) and have that perform an action when it happens, and also return resultImage to its starting location.

  • 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-06-18T03:47:49+00:00Added an answer on June 18, 2026 at 3:47 am

    Off the top of my head, you can use CGRectContainsPoint four times using the target’s frame and the moving image’s four corners to see if they touch.

    if(CGRectContainsPoint(collisionTarget.frame, resultImage.frame.origin) ||
       CGRectContainsPoint(collisionTarget.frame, CGPointMake(resultImage.frame.origin.x,resultImage.frame.origin.y+resultImage.frame.size.height)) ||
       CGRectContainsPoint(collisionTarget.frame, CGPointMake(resultImage.frame.origin.x+resultImage.frame.size.width,resultImage.frame.origin.y)) ||
       CGRectContainsPoint(collisionTarget.frame, CGPointMake(resultImage.frame.origin.x+resultImage.frame.size.width,resultImage.frame.origin.y+resultImage.frame.size.height)){
        //do something
    }
    

    EDIT: I completely forgot about CGRectIntersectsRect. You can just use that.

    if(CGRectIntersectsRect(imageView1.frame,imageView2.frame)){
        //do something
    }
    

    Just do the above check in your touchesMoved method right after moving the first image view using the frames of your two image views. Then, restore the first one’s position to where it was some point earlier in time. You need to have stored its position in a property or something earlier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to put two images together (a nine-patch image with icon), So that
I have two divs one inside of the other, now i want to put
I want to put two EditText control in a LinerLayout. And put them one
I want to put two <div> s next to each other. The right <div>
How can i put two instance of a group on one page in .RDLC
I want put this two value together (Side by side), as following image, but
If I have output from two sources that I want to put together on
I have a desktop C# app that I want to split into two parts
I want to put two small buttons, one on left side ( info )
I want to overlap two image. For that, I use JLabel and set an

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.