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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:54:07+00:00 2026-06-05T01:54:07+00:00

i wonder if you guys have a sample code adding and move UIImageView on

  • 0

i wonder if you guys have a sample code adding and move UIImageView on touch and also detect if there is an UIImageView there so i can’t add UIImageView on top of it.

EDIT: clearer question
1. i wanna add an cups(UIImageView) when i touch the view but do not wan the cup(UIImageView) to stack.

  1. i wanna move the UIImageView but will bounce back to the original position if there is an UIImageView there so it will not stack the UIImageView already there.

thanks for reading my question and appreciated your helps

cheers

des

  • 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-05T01:54:08+00:00Added an answer on June 5, 2026 at 1:54 am

    This should let you going…

    Create two ivars in your header file:

    UIImageView *myImageView1;
    UIImageView *myImageView2;
    

    The next two methods will be in your implementation file:

    -(void)initImagesAndPanGesture
    {
        UIImage *img = [UIImage imageNamed:@"image1.png"];
        myImageView1 = [[UIImageView alloc]initWithImage:img];
        [myImageView1 setFrame:CGRectMake(300, 800, 100, 100)];
        [myImageView1 setUserInteractionEnabled:YES];
        UIPanGestureRecognizer *recognizer1 = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan1:)];
        [myImageView1 addGestureRecognizer:recognizer1];
        [self.view addSubview:myImageView1];
    
        img = [UIImage imageNamed:@"image2.png"];
        myImageView2 = [[UIImageView alloc]initWithImage:img];
        [myImageView2 setFrame:CGRectMake(500, 800, 100, 100)];
        [myImageView2 setUserInteractionEnabled:YES];
        recognizer1 = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan1:)];
        [myImageView2 addGestureRecognizer:recognizer1];
        [self.view addSubview:myImageView2];
    }
    
    -(void)handlePan1:(UIPanGestureRecognizer *)recognizer
    {
        if (!(CGRectIntersectsRect(myImageView1.frame, myImageView2.frame)))
        {
            CGPoint translation = [recognizer translationInView:self.view];
            recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, 
                                             recognizer.view.center.y + translation.y);
    
            [recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
        }
        else 
        {
            NSLog(@"intersect!");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys I have a router (Belkin) so I wonder how can I see
wonder whether someone can help me with the following one... I have a struct
I know I can download Wikipedia entirely. But I wonder if there is any
I am learning PHP by myself and I wonder if you guys can help
Guys can you suggest me any software who have some similarities with Microsoft's SQL
hey guys, i have a form that can be influenced with up and down
I wonder if you can help me with this one. I have looked on
I wonder if any of you guys can help me with what I think
I wonder if you guys could help me. I have a table called modules
I wonder if you guys can help me creating a regular expression for validating

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.