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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:12:04+00:00 2026-06-10T07:12:04+00:00

I am trying recognize gestures in a subview. I only get response when i

  • 0

I am trying recognize gestures in a subview. I only get response when i define the gestureRecognizer in the superview. I wanted to know why i am not getting the gestutre response when i define it with in the subview which in my case is ‘View.m’, although i get response when i define the gestureHandler in the superview which in my case is the view of ViewController but i want why it isnt working in subview. The Code Will Make it more clear. Also the gestures arent recognized during Animation as in my case im moving the subview from left to right in my ‘view.m’ and when i click during animation gestures arent recognized . i have tried UIViewAnimationOptionAllowUserInteraction but still no gestures are recognized.

This is the SubView Class With a TapgesturHandler

//  View.m
//  GestrureonImageView
//
//  Created by Noman Khan on 8/24/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "View.h"

@implementation View

- (id)initWithFrame:(CGRect)frame
{

    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }

    UITapGestureRecognizer *tapGestures=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gesturesCallBack:)];

    // NSLog(@"init gestures");

    [tapGestures setDelegate:self];

    // Set required taps and number of touches
    [tapGestures setNumberOfTapsRequired:1];
    [tapGestures setNumberOfTouchesRequired:1];
    [self addGestureRecognizer:tapGestures];
    return self;
}
-(void) gesturesCallBack:(UITapGestureRecognizer *)sender 
{
    NSLog(@"abcView");
    [UIView animateWithDuration:10 

                          delay:0.1
                        options:UIViewAnimationOptionAllowUserInteraction
                     animations:^
     {
         // [self initGestures];
         CGAffineTransform transform = CGAffineTransformMakeTranslation(500,0);

         self.transform = transform;
     }
                     completion:^(BOOL finished){


                     }];   

}



-(void)viewDidLoad{

    NSLog(@"Inview");

}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end

And View.h

//  View.h
//  GestrureonImageView
//
//  Created by Noman Khan on 8/24/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface View : UIView<UIGestureRecognizerDelegate>

@end

This is ViewController.m class

//  ViewController.m
//  GestrureonImageView
//
//  Created by Noman Khan on 8/24/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize v;

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

-(void) gesturesCallBack:(UITapGestureRecognizer *)sender 
{
    NSLog(@"abc");

}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor blueColor]];

    UITapGestureRecognizer *tapGestures=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gesturesCallBack:)];

   // NSLog(@"init gestures");

    [tapGestures setDelegate:self];

    // Set required taps and number of touches
    [tapGestures setNumberOfTapsRequired:1];
    [tapGestures setNumberOfTouchesRequired:1];

    [self.view addGestureRecognizer:tapGestures];
    v=[[View alloc]initWithFrame:CGRectMake(40, 50, 80, 50)];
    v.backgroundColor=[UIColor yellowColor];
//    [v addGestureRecognizer:tapGestures];    
    [self.view addSubview:v];


    // Do any additional setup after loading the view.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

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

@end

this is my ViewController.h

//  ViewController.h
//  GestrureonImageView
//
//  Created by Noman Khan on 8/24/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

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

@interface ViewController : UIViewController <UIGestureRecognizerDelegate>


@property(nonatomic,strong)View *v;

@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-06-10T07:12:06+00:00Added an answer on June 10, 2026 at 7:12 am

    Just try setting v.userInteractionEnabled = YES

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

Sidebar

Related Questions

I'm trying to compile this but I get the error error: ‘setioflags’ was not
I've recently been trying to figure out how to get PyCrypto to recognize PEM's
I am trying to get apache/php to recognize the path to my git. I
I'm trying to develop a program to recognize a hand gestures and base on
I'm trying to login to a login.live.com, but Mechanize will not recognize that there
I am trying to get input from the user and need to know a
I've been trying to get sscanf to recognize a fairly simple format using character
Strangest thing: I'm trying to get facebook to recognize the & sign within the
I'm trying to get my web app to recognize my working directory. When running
I am new in iPhone programming. At the moment I am trying to recognize

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.