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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:49:55+00:00 2026-05-29T21:49:55+00:00

In my code I have an array of objects which are UIImageViews with UIImages

  • 0

In my code I have an array of objects which are UIImageViews with UIImages in them.

I use a for loop in -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event to move all objects from the array one by one.

Once they are moved to different positions on the main view I would like to be able to grab any of those objects and move them somewhere else.

I’m not sure how best to do this. Is there a way I can use touchesbegin so that I can drag only the item I clicked on?

Basically, there are five UIImageViews there now and each one has UIImage and I am trying to get to the point where when i click on any of them they are able to move around.

  • 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-29T21:49:56+00:00Added an answer on May 29, 2026 at 9:49 pm

    I’ve done something similar with great success using the UIPanGestureRecognizer in my draggable view. To hook it up, it might look something like this:

    @implementation DraggableView
    
    -(id)initWithFrame:(CGRect)frame
    {
       ...
       ...
       UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)] autorelease];
       [self addGestureRecognizer:panGesture];
       ..
       return self;
    }
    @end
    

    In your pan: method, you could check the state of the gesture and even capture the gesture’s location and use it to relocate your view. Here’s a rough example of what it might look like:

    -(void)pan:(UIPanGestureRecognizer *)gesture
    {
    
       if (gesture.state==UIGestureRecognizerStateChanged)
       {
          //We're moving!
          UIView *aRootView = <perhaps your root view controller's view>;
          CGPoint currentOrigin = [gesture translationInView:aRootView];
          self.frame = CGRectMake(currentOrigin.x,currentOrigin.y,self.frame.size.width,self.frame.size.hight);
          ...
          ...
       }
    
    }
    

    Here is more reading on the UIPanGestureRecognizer.

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

Sidebar

Related Questions

I have code similar to this filtering entries in an Array of Objects: var
I have some code where I'm returning an array of objects. Here's a simplified
I have some code which builds an array of date ranges. I then call
I have an array of objects which I want to serialize as XML. These
I have an array of objects which was fetched from a JSON (JSONP) file
I have an array of objects which created from a custom class. The custom
I have an array myArr which contains objects of custom class..e.g. objs of type
I have an array of objects, each of which is assigned an ID when
I have an array of NSMutableDictionary objects which are displayed in a master–detail interface
I'm building an array of objects which have a property of type array: here's

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.