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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:57:36+00:00 2026-06-10T00:57:36+00:00

I am having my UIImageView onto which I am having another UIView rectangle. By

  • 0

I am having my UIImageView onto which I am having another UIView rectangle. By applying pan gesture to UIView rectangle it gets outside of UIImageView also. I don’t want to be drag outside of UIImageView

I have tried below code but it is not working that way

-(void)handleMovementView:(UIPanGestureRecognizer *)recognizer
{
    CGPoint movement;

    if(recognizer.state == UIGestureRecognizerStateBegan || recognizer.state == UIGestureRecognizerStateChanged || recognizer.state == UIGestureRecognizerStateEnded)
    {
        CGRect rec = recognizer.view.frame;
        CGRect imgvw = self.imgViewCrop.frame;
        if((rec.origin.x >= imgvw.origin.x && (rec.origin.x + rec.size.width <= imgvw.origin.x + imgvw.size.width)))
        {
            CGPoint translation = [recognizer translationInView:recognizer.view.superview];
            movement = translation;
            recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y);
            [recognizer setTranslation:CGPointZero inView:recognizer.view.superview];
            [self handleMovementForHandlers:movement];
        }
    }

}

If i apply Pan slowly it applies this condition but when i go fast it went outside of 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-06-10T00:57:37+00:00Added an answer on June 10, 2026 at 12:57 am

    Try This

    -(void)handleMovementView:(UIPanGestureRecognizer *)recognizer
    {
    CGPoint movement;
    
    if(recognizer.state == UIGestureRecognizerStateBegan || recognizer.state == UIGestureRecognizerStateChanged || recognizer.state == UIGestureRecognizerStateEnded)
    {
        CGRect rec = recognizer.view.frame;
        CGRect imgvw = self.imgViewCrop.frame;
        if((rec.origin.x >= imgvw.origin.x && (rec.origin.x + rec.size.width <= imgvw.origin.x + imgvw.size.width)))
        {
            CGPoint translation = [recognizer translationInView:recognizer.view.superview];
            movement = translation;
            recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y);
            rec = recognizer.view.frame;
    
            if( rec.origin.x < imgvw.origin.x )
                rec.origin.x = imgvw.origin.x;
    
            if( rec.origin.x + rec.size.width > imgvw.origin.x + imgvw.size.width )
                rec.origin.x = imgvw.origin.x + imgvw.size.width - rec.size.width;
    
            recognizer.view.frame = rec;
    
            [recognizer setTranslation:CGPointZero inView:recognizer.view.superview];
            [self handleMovementForHandlers:movement];
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a problem setting a UIImageView or UIView on the cell of
I am having problem with detecting swipe on UIImageView which is inside self.view. When
I'm having a problem with the following code. I want to use one UIImageView
I have an image pattern which I want to display in a UIImageView. The
I am having a View1 which has a UIImageView where I am loading a
I want to insert UIImageView in UITextView of Toolbar having send and camera button
I'm having a memory problem related to UIImageView. After adding this view to my
I'm having an intermittent problem when I move a UIImageView around the screen using
I am having a problem setting the background of UITableView to a UIImageView (see
I'm having trouble adding an image in xCode 4.2. When I'm inserting an UIimageview

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.