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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:56:15+00:00 2026-06-10T09:56:15+00:00

I have a view that contains a UIScrollView. The UIScrollView contains an UIImageView (only

  • 0

I have a view that contains a UIScrollView. The UIScrollView contains an UIImageView (only one for now but there will be more latter). I want to be able to drag the UIImageView out of the UIScrollView and into the superview.

I have reviewed every similar question and example I can find online and still cant get my head around how this works.

At first I couldn’t get touches to register all whithin the scrollview. After a lot of searching I have found a way to get touchesbegan to register as follows:

First I created a new view based project and in the auto-created “ViewController.h”
I created an IBOutlet named slider.

Then in the auto-created “ViewController.m” I created the UIScrollview.

In IB I added a UIScrollView to the storyboard then connected it to the “slider” IBOutlet.

Next I added class file to the projects. This new class is a subclass os UIImageView. I named this class “DragableImage” In the

Then in IB I dropped an image into the UIScrollview clicked on it and changed the class to “DragableImage”

In the DragableImage.m I voided touches began and simply told it to become hidden if clicked.

This works and the touch registers and makes the image disappear but how do I now add the new image to the main view and have it follow my finger?

This is what I have in the way of code:

ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {

    IBOutlet UIScrollView *slider;
}

@end

ViewController.m

#import "ViewController.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [slider setScrollEnabled:YES];
    [slider setContentSize:CGSizeMake(306, 1560)];
    [slider setShowsVerticalScrollIndicator:NO];
    slider.canCancelContentTouches = NO; 
    slider.delaysContentTouches = NO;

    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

@end

DragableImage.h

#import <UIKit/UIKit.h>

@interface DragableImage : UIImageView

@end

DragableImage.m

@implementation DragableImage

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

    self.hidden = YES;
}

@end

How to make this work?

  • 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-10T09:56:17+00:00Added an answer on June 10, 2026 at 9:56 am

    There is one obvious problem that can arise here. Namely, how to tell the difference between dragging to scroll and dragging an image. The way I would handle this is to setup a tap and hold gesture recognizer (http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html).

    Once you detect a hold you could set it up so that further touches/gestures get routed to you drag and drop code. You can find a nice tutorial for that here:
    http://www.ancientprogramming.com/2012/04/05/drag-and-drop-between-multiple-uiviews-in-ios/

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

Sidebar

Related Questions

I have a View that contains a ParentModel, which contains 2 Models. I only
I have a scroll view that is the width of the screen but only
I have a UIScrollView that contains a UIToolbar, but when I scroll, the toolbar
I have a list view that contains some data, I want to share it
I have a UIScroll View that scrolls vertically, each cell contains a UIScrollView that
I have a view that contains two NSTextFieldCell s. The size at which these
I have a view model that contains a Product class type and an IEnumerable<
I'm developing an iOS 4 application. I have a main view that contains another
I have a hypothetical tree view that contains this data: RootNode Leaf vein SecondRoot
I have developed a small view that contains special char like 'é' and when

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.