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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:27:01+00:00 2026-05-28T01:27:01+00:00

How do I pass the touches events down to my viewcontroller? I think the

  • 0

How do I pass the touches events down to my viewcontroller? I think the UIScrollView is interecepting the touches and causeing the touches events that I have in the view controller not to fire

Code snippet:

    //
//  DragDrop.m
//  Ballet
//
//  Created by  on 1/10/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "DragDrop.h"
#import "BAScrollView.h"

@implementation DragDrop

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization

        [self.view setBackgroundColor:[UIColor whiteColor]];
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];

    sv = [[BAScrollView alloc] initWithFrame:self.view.frame];


    [sv setBackgroundColor:[UIColor redColor]];

    UIImageView *dragImage2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img-thumb-10-mindful.png"]];

    [dragImage2 setUserInteractionEnabled:YES];

    dragImage2.frame = CGRectMake(0, 0, 64, 64);

    [sv addSubview:dragImage2];


    [self.view addSubview:sv];

    //this image works as expected
    UIImageView *dragImage3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img-thumb-10-mindful.png"]];

    [dragImage3 setUserInteractionEnabled:YES];

    dragImage3.frame = CGRectMake(200, 200, 64, 64);

    [self.view addSubview:dragImage3];
}


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

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

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

    if ([touch.view isKindOfClass:[UIImageView class]])
    {
        dragImage = [[UIImageView alloc] initWithImage:((UIImageView *)(touch.view)).image];
        dragImage.frame = CGRectMake(100, 100, 64, 64);//touch.view.frame;
        [dragImage setUserInteractionEnabled:YES];
      //  CGPoint point = [[[event allTouches] anyObject] locationInView:super.view];

        //dragImage.frame = 
       // dragImage.center = point;
        [self.view addSubview:dragImage];



    }



}


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

    NSLog(@"MOVED");

    if (dragImage!=nil) {
        CGPoint point = [[[event allTouches] anyObject] locationInView:self.view];

        dragImage.center = point;
    }





}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (dragImage != nil)
    {

        [dragImage removeFromSuperview];
        [dragImage release];
        dragImage = nil;
    }
}


@end
  • the SCROLLVIEW SUB-CLASS

//
// BAScrollView.m
// Ballet
//
// Created by n 1/10/12.
// Copyright (c) 2012 MyCompanyName. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BAScrollView.h"

@implementation BAScrollView

- (id)initWithFrame:(CGRect)frame 
{
    return [super initWithFrame:frame];
}

- (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 
{   
    // If not dragging, send event to next responder
    if (!self.dragging) 
        [self.nextResponder touchesEnded: touches withEvent:event]; 
    else
        [super touchesEnded: touches withEvent: event];
}



@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-28T01:27:02+00:00Added an answer on May 28, 2026 at 1:27 am

    There is a good article about Responder Chain by Jeff Lamarche

    In your case, you can subclass your scroll view and delegate your touch event to the next one in the responder chain.

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        if(condition) // you want scroll to happen
            [super touchesBegan:touches withEvent:event];
        else // you want to delegate your touch to the next responder
            [self.nextResponder touchesBegan:touches withEvent:event];
    }
    

    This is not tested code, but I hope you get the idea.

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

Sidebar

Related Questions

I have a view hierarchy that is layed out as follows: parentView scrollView contentViewA
I have a UIWebView that has userInteractionEnabled=YES . It intercepts all touches and won't
Let's say we have a view controller with one sub view. the subview takes
I have a UIViewController, on top I put an UIImageView, then a UIScrollView. I
I have a UIViewController, and I've added two subviews to its view. One subview
Basically i have an application for Android 1.5 with a GLSurfaceView class that shows
I'm trying to debug some touchesBegan/Moved/Ended related slowdown in my game; I think that
I am writing a simple app where I have a UIImageView that when clicked
I need to pass the touches and event from touchesBegan to my own method
So I wanted to make my UIWebview respon to touch events. I have read

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.