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

  • Home
  • SEARCH
  • 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 8847819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:16:55+00:00 2026-06-14T12:16:55+00:00

This is what I have so far -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch

  • 0

This is what I have so far

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [[event allTouches] anyObject];

    for (UIImageView *imageView in _imageViewArray) {
            CGPoint Location = [touch locationInView:touch.view];
            imageView.center = Location;
    }   
}

The problem I am facing is when I move one image they all jump to the same place.

Thanks to cyberpawn this it what I did it get it to work

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];

    CGPoint oldPoint = [touch previousLocationInView:touch.view];
    CGPoint newPoint = [touch locationInView:touch.view];

    CGPoint diff = CGPointMake(newPoint.x - oldPoint.x, newPoint.y - oldPoint.y);

    for (UIImageView *imageView in _imageViewArray) {
        if (CGRectContainsPoint(imageView.frame, newPoint)) {
            CGPoint cntr = [imageView center];
            [imageView setCenter:CGPointMake(cntr.x + diff.x, cntr.y + diff.y)];

        }
}
}
  • 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-14T12:16:56+00:00Added an answer on June 14, 2026 at 12:16 pm

    Thats because you are moving them all to same location, you need to calculate the difference between touch locations and add that displacement to all views. Below code should solve your problem! Forget touchesBegan and Just override touchesMoved method like that.

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];
    
        CGPoint oldPoint = [touch previousLocationInView:touch.view];
        CGPoint newPoint = [touch locationInView:touch.view];
    
        CGPoint diff = CGPointMake(newPoint.x - oldPoint.x, newPoint.y - oldPoint.y);
    
        for (UIImageView *imageView in _imageViewArray) {
            CGPoint cntr = [imageView center];
            [imageView setCenter:CGPointMake(cntr.x + diff.x, cntr.y + diff.y)];
        }
    }
    

    If You want to move them separately when any of them is clicked than use below code instead!

    float oldX, oldY;
    
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];
        CGPoint pt = [touch locationInView:touch.view];
        for (UIImageView *imageView in _imageViewArray) {
            if(CGRectContainsPoint(imageView.frame, pt)) {
                oldX = imageView.center.x - imageView.frame.origin.x - pt.x;
                oldY = imageView.center.y - imageView.frame.origin.y - pt.y;
                break;
            }
        }
    }
    
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [[event allTouches] anyObject];
        CGPoint pt = [touch locationInView:touch.view];
    
        for (UIImageView *imageView in _imageViewArray) {
            if (CGRectContainsPoint(imageView.frame, pt)) {
                [self setCenter:CGPointMake(pt.x+oldX, pt.y+oldY)];
            }
        }
    

    Enjoy Programming!

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

Sidebar

Related Questions

im learning wpf for the first time, i have made this far private void
This is what I have so far: void sort(const E &t) { DNode<E> *tmp
I have this so far but the Column 'name' is ambiguous, so I want
I have this so far but I don't know how to write over the
I have this so far: http://jsfiddle.net/u5vhS/54/ . What I want to be able to
So far i have this: mov ah,02h mov cl,11001100001111011101000b ;6,692,584 in dec mov dl,0
I'm using the javascript module pattern, and have this so far: var APP; if(APP
Thanks to everyone out there helping newbies like me. So far I have this:
This is what I have so far: [my1@graf home]$ curl -# -o f1.flv 'http://osr.com/f1.flv'
This is what I have so far - my dropbox public URL creation script

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.