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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:08:46+00:00 2026-05-31T00:08:46+00:00

First of all, this problem did not exist in iOS 4.3. I can still

  • 0

First of all, this problem did not exist in iOS 4.3. I can still run the program in iOS 4.3 and won’t see any problem. Secondly, this is an iPad app.

The problem is that when I hold down an image and drag it, it won’t be dragged. It worked in iOS 4.3 but not iOS 5.

I created new testing project and cleared everything that’s not needed. The project I chose is a Single View Application and did not alter any of the AppDelegate files.

Here is the code.

myUIScrollViewClass.h

#import <UIKit/UIKit.h>


@interface myUIScrollViewClass : UIScrollView
{
}

@end

myUIScrollViewClass.m

#import "myUIScrollViewClass.h"


@implementation myUIScrollViewClass


- (id)init
{
    self = [super init];

    if (self) 
     {
     }

    return self;
}

- (void)didReceiveMemoryWarning
{
    [self didReceiveMemoryWarning];
}


-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
     [self.nextResponder touchesBegan: touches withEvent:event]; 
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{      
     [self.nextResponder touchesMoved: touches withEvent:event]; 
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

{
     [self.nextResponder touchesEnded: touches withEvent:event]; 
}

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

{
     [self.nextResponder touchesCancelled: touches withEvent:event]; 
}

@end

ViewController.h

#import <UIKit/UIKit.h>
#import "myUIScrollViewClass.h"

@interface ViewController : UIViewController <UIScrollViewDelegate>
{
     myUIScrollViewClass *mainScrollView_;
     UIImageView *aTouchedImage_;
}

@property (retain, nonatomic) myUIScrollViewClass *mainScrollView_;
@property (retain, nonatomic) UIImageView *aTouchedImage_;

@end

ViewController.m

#import "ViewController.h"

@implementation ViewController

@synthesize mainScrollView_;
@synthesize aTouchedImage_;

- (void)didReceiveMemoryWarning
{
     [super didReceiveMemoryWarning];
     // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
     mainScrollView_ = [[myUIScrollViewClass alloc] initWithFrame:self.view.frame];
     [self.view addSubview:mainScrollView_];

     mainScrollView_.delegate = self;
     mainScrollView_.contentSize = CGSizeMake(1024, 768);
     mainScrollView_.clipsToBounds = YES;
     mainScrollView_.bounces = NO;
     mainScrollView_.bouncesZoom = NO;
     mainScrollView_.showsVerticalScrollIndicator = NO;
     mainScrollView_.showsHorizontalScrollIndicator = NO;
     mainScrollView_.backgroundColor = [UIColor whiteColor];
     mainScrollView_.userInteractionEnabled = YES;

     aTouchedImage_ = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"image1.png"]];
     [aTouchedImage_ setFrame:CGRectMake(0, 0, 80, 80)];
     [mainScrollView_ addSubview:aTouchedImage_];
     [aTouchedImage_ setCenter:CGPointMake(512, 334)];


     [super viewDidLoad];
     // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{     
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
     [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
     [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     // Return YES for supported orientations
     return YES;
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)anEvent
{
     mainScrollView_.scrollEnabled = NO;


     for (UITouch *touch in touches) 
     {
          [aTouchedImage_ setCenter:[touch locationInView:self.view]];
     }
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)anEvent
{           
     mainScrollView_.scrollEnabled = NO;


     for (UITouch *touch in touches) 
     {
          [aTouchedImage_ setCenter:[touch locationInView:self.view]];
     }
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)anEvent
{
     mainScrollView_.scrollEnabled = YES;


     for (UITouch *touch in touches)
     {        
     }
}

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)anEvent
{
    mainScrollView_.scrollEnabled = YES;

    for (UITouch *touch in touches) 
    {
    }
}

@end
  • 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-31T00:08:47+00:00Added an answer on May 31, 2026 at 12:08 am

    It seems I will answer my own question.

    I have requested a support from Apple Developer Technical Support, and they told me to place my code in the UIScrollView rather than passing the touch events to another view. Apple themselves admitting that there is a problem with passing touch events.

    Here is an extract of their reply:

    “It looks like not all touch events are getting through to your view controller. Your UIScrollView is blocking touch events from getting through, even though is forwards those events to the next responder. The behaviour is very erratic, some touch events are being forwarded to your view controller, but not all of them.”

    “Looks like a behaviour change in iOS 5.0.x. My guess it’s because of the view controller containment feature that was introduced.”

    The other way to do it is to use UIGestureRecognizer to implement dragging of views. Something like the code below:

    - (void)viewDidLoad 
    {
        // ... other initialization code here
    
        UILongPressGestureRecognizer *longPress = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(dragChild:)] autorelease];
        [longPress setMinimumPressDuration:0]; // recognize immediately when a finger comes down
        [draggableView addGestureRecognizer:longPress];
    }
    
    - (void)dragChild:(UILongPressGestureRecognizer *)longPress 
    {
        [[longPress view] setCenter:[longPress locationInView:[[longPress view] superview]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all: This question is not directly programming related. However, the problem only
first of all: this is not the same as this . The ModelBackend has
First of all I'm not sure this is even possible, however I need to
First of all I did gave a look at this one. But I didn't
First of all this is my markup: <div class=first></div> <div class=second></div> <div class=second></div> <div
first of all this is my third question about web services here and i
Well, first of all sorry about this question it must be pretty straight forward
Maybe it's a similar beginning, but it's true. first of all sorry if this
First of all there is probably a question like this already but i couldn't
First of all I don't know if this is the right approach. I want

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.