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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:21:35+00:00 2026-05-26T04:21:35+00:00

I have two imageViews imageView1 and imageView2. I have given gestureRecognizer to move these

  • 0

I have two imageViews imageView1 and imageView2. I have given gestureRecognizer to move these both images. Now the problem is when i move first imageView near second imageView only second image view is displayed. But when i put first imageView on another image the first imageView should be displayed on the second imageView which is not happening.Can any body please tell me how can the first imageView gets view on the top of another imageView.

  • 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-26T04:21:35+00:00Added an answer on May 26, 2026 at 4:21 am

    Why dont you use something similar like this to drag your UIImageViews?

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    
        self.view.backgroundColor = [UIColor yellowColor];
    
        test1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
        test1.backgroundColor = [UIColor whiteColor];
        test1.userInteractionEnabled = YES;
        test1.clipToBounds = YES;
        [self.view addSubview:test1];
    
        test2 = [[UIImageView alloc] initWithFrame:CGRectMake(400, 400, 100, 100)];
        test2.backgroundColor = [UIColor whiteColor];
        test2.userInteractionEnabled = YES;
        test2.clipToBounds = YES;
        [self.view addSubview:test2];
    }
    
    
    CGPoint startLocation;
    float diffX;
    float diffY;
    
    -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch = [[event allTouches] anyObject];
    
        if( [touch view] == test1)
        {
            startLocation = [touch locationInView:self.view];
            [self.view bringSubviewToFront:test1];
        }
    
        if( [touch view] == test2)
        {
            startLocation = [touch locationInView:self.view];
            [self.view bringSubviewToFront:test2];
        }
    }
    
    
    - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    
        UITouch *touch = [[event allTouches] anyObject];
    
        if( [touch view] == test1)
        {
            CGPoint location = [touch locationInView:self.view];
            diffX = location.x - startLocation.x;
            diffY = location.y - startLocation.y;
            test1.frame = CGRectMake(test1.frame.origin.x + diffX, test1.frame.origin.y + diffY, test1.frame.size.width, test1.frame.size.height);
            startLocation = test1.frame.origin;
        }
    
        if( [touch view] == test2)
        {
            CGPoint location = [touch locationInView:self.view];
            diffX = location.x - startLocation.x;
            diffY = location.y - startLocation.y;
            test2.frame = CGRectMake(test2.frame.origin.x + diffX, test2.frame.origin.y + diffY, test2.frame.size.width, test2.frame.size.height);
            startLocation = test2.frame.origin;
        }
    
    }
    

    //—EDIT—//
    Added: cliptobounds in viewdidload

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

Sidebar

Related Questions

In a ViewGroup I want to put two ImageViews overlapping: The imageview A have
Now I have four Images and I have applied frame animation on these four
I am creating an app, in which I have two small imageview (using have
I have list with items having two textview and one imageview.I inflate the list
I have two imageViews that I call firstView and secondView; I have to do
I have a layout with two ImageView inside. Each image has a fixed aspect
If I have a layout with two ImageViews. Their id's are image_one and image_two.
I have two ImageView s, one TextView and one Gallery in my app and
i'm studying iOS programming. but i have a problem, which is opaque. now assume.
Firstly sorry about my grammar. I have two ImageViews and I want to swap

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.