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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:47:23+00:00 2026-05-12T06:47:23+00:00

I am trying to drag a UIImageView around the iphone screen in my app.

  • 0

I am trying to drag a UIImageView around the iphone screen in my app.

Currently The drag functionality I have set up is fine and dragging the image does move it around the screen, the trouble is that you don’t have to drag the image view to move it, you can also drag anywhere on the screen and it will move the image.
I am new to this platform so I can’t really think about what to do to solve this issue.
My current code to drag the image is:

 - (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
    CGPoint pt = [[touches anyObject] locationInView:pig];
    startLocation = pt;


}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
    CGPoint pt = [[touches anyObject] locationInView:pig];
    CGRect frame = [pig frame];
    frame.origin.x += pt.x - startLocation.x;
    frame.origin.y += pt.y - startLocation.y;
    [pig setFrame: frame];
}

Any help appreciated. By the way pig is the UIImageView.
Also I have noticed that if I set the user interaction of the Image View “pig” to enabled the image is no longer drag able,but when it isn’t set to enabled It is.

  • 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-12T06:47:23+00:00Added an answer on May 12, 2026 at 6:47 am

    You can try to subclass UIImageView and implement touchesBegan: and touchesMoved: on it directly. Then in InterfaceBuilder select your subclass for the UIImageView.

    alt text http://img.skitch.com/20090728-xetretcfubtcj7ujh1yc8165wj.jpg

    Oh yes, now you will need to set the user interaction again…

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

Sidebar

Related Questions

I'm trying to create a WPF application where I can drag an image around.
I'm trying to drag a UIImageView according to an anchorPoint but the whole image
I'm trying to drag a CALayer in an iOS app. As soon as I
I am currently trying to code my own JS drag and drop script (out
so I am trying to drag around some images in a canvas. I am
I am trying to drag a view over the screen FrameLayout main = (FrameLayout)
I'm trying to drag some text (a plain string) from an app. NSString *text
I'm trying to explore UIImageView so I added an image Logo.jpg to my projet
i was trying to drag and drop an image inside a panel of extjs.
I'm trying to drag an image and let it return to it's original position

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.