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 3234744
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:25:37+00:00 2026-05-17T17:25:37+00:00

We are adding drag and drop functionality to what is to become a sports

  • 0

We are adding drag and drop functionality to what is to become a sports field with positions for players.

The positions are mapped out using Interface Builder with each being a separate UIImageView.

We want to be able to drag player images from bench positions from the side of the screen onto positions on the field.

How best can we detect when the selected player which is being moved around collides with an existing gamePosition imageView?

We are looking for a way to detect if there is a view or ImageView under the current location.

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
  UITouch *touch = [[event allTouches] anyObject];
  CGPoint location = [touch locationInView:touch.view];
  tile1.center = location;  

  if gamePositionExistsAtCurrentLocation(location) { //want something like this
    [tile1 setBackgroundColor:[UIColor blueColor]]; 
  } else {
   [tile1 setBackgroundColor:[UIColor yellowColor]]; 
  }
}
  • 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-17T17:25:38+00:00Added an answer on May 17, 2026 at 5:25 pm

    check if the frame of the item you are moving intersects with the frame from on of your subviews

    for (UIView *anotherView in self.subviews) {
        if (movingView == anotherView)
            continue;
        if (CGRectIntersectsRect(movingView.frame, anotherView.frame)) {
            // Do something
        }
    }
    

    If I were you, I would add all game relevant items to an NSArray and for-loop through this. So you don’t detect collisions with subviews that have nothing to do with your game like labels and so on.

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

Sidebar

Related Questions

I am working on a large application and am adding some drag/drop functionality to
I am trying to make a drag drop stage using Jquery, I am having
I have tried using drag n drop to place the control as well as
I am in the process of adding drag and drop support to an existing
I'm adding some code to my project that allows drag and drop. The Form
I'm trying to make a drag-and-drop engine in JavaScript. Right now, I'm adding a
I'm looking at adding scripting functionality to an existing codebase and am weighing up
I'm working with the Adorner model with drag and drop, and I'm instantiating a
I am trying to implement drag and drop between two listboxes. I have a
i've created a sprite to drag and drop around the stage. the sprite is

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.