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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:12:21+00:00 2026-05-25T14:12:21+00:00

Is it possible to pan a UIImageView and when it intersects with the frame

  • 0

Is it possible to pan a UIImageView and when it intersects with the frame of another UIImageView, have that other UIImageView be pushed around by the other UIImageView without just passing over it? I hope that makes sense!

If it is possible, could you give me some ideas on how I’d go about implementing this?

I imagine it would go something like…

If frame intersects frame from left or right on the x/y axis, have the other frame move in that same direction with same distance as the pushing frame. While that logic somewhat makes sense to me, I’m not sure how I’d implement that in code.

I’d really appreciate any advice you can offer.

  • 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-25T14:12:21+00:00Added an answer on May 25, 2026 at 2:12 pm

    So, you’re only concerned with left / right panning…

    Let’s assume you have 2 UIImageViews, a & b, as subviews of some other UIView and defined as class members of some class.

    You can get help detecting panning gestures (dragging touches) on each of these views by creating instances of UIPanGestureRecognizer and adding them to each UIImageView using method addGestureRecognizer:

    When creating each UIPanGestureRecognizer, you need to designate a selector to receive the gesture events. Let say it’s called didMove:

    Now, some sample code:

    - (void) didMove:(UIPanGestureRecognizer*)recognizer {
        UIView* view = [recognizer view];
    
        // Remember our UIImageViews are class members called, a & b
        //
        UIView* otherView = view == a ? b : a;    
    
        if (recognizer.state == UIGestureRecognizerStateBegin 
            || recognizer.state == UIGestureRecognizerStateChanged) {
    
            // Moving left will have a negative x, moving right positive
            //
            CGPoint translation = [recognizer translationInView:view.superview];
            view.center = CGPointMake(view.center.x + translation.x, view.center.y);
    
            // Reset so we always track the translation from the current view position
            //
            [recognizer setTranslation:CGPointZero inView:view.superview];
    
            if (CGRectIntersectsRect(view.frame, otherView.frame)) {
                // Translate by the same number of points to keep views in sync
                //
                otherView.center = CGPointMake(otherView.center.x + translation.x, otherView.center.y);
            }
        }
    }
    

    It may not be exactly what you need, but it should give you a good idea how it could be done.

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

Sidebar

Related Questions

Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
I have some images that I loaded from a remote source stored in Bitmap
I have a view that I have overridden the onDraw method to output the
Possible Duplicate: regex for URL including query string I have a text or message.
Possible Duplicate: Why do I get a null pointer exception from TabWidget? I have
I want to create a chart that looks as much as possible like Google
Possible Duplicate: Python urllib2 Progress Hook I have a script which uploads a file
I have an OpenGL application which implements navigation functions such as Orbit, Walk, Pan,
Possible Duplicate: C++ templates that accept only certain types For example, if we want
Possible Duplicate: css rule to disable text selection highlighting On my homepage i have

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.