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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:03:33+00:00 2026-05-15T19:03:33+00:00

I want to call an action in two classes (a superview and a full

  • 0

I want to call an action in two classes (a superview and a full screen subview) when the user single taps the screen. But, when I add a UITapGestureRecognizer to the subview, the one added to the superview is overridden. Is it possible to add a UITapGestureRecognizer to a subview without overriding the UITapGestureRecognizer added to the superview?
If so, how can I do this?

Thanks!

Edit:
From my main viewController “MyToolBerController”, I’m adding the subview from another viewController as follows:

PhotoViewController *photoViewController = [[PhotoViewController alloc] initWithNibName:@"PhotoViewController" bundle:nil];
myPhotoView = photoViewController.view;
[self.view addSubview:myPhotoView]; 

I add the GestureRecognizer in the MyToolBerController like this:

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTapFrom:)];        
[singleTap setNumberOfTapsRequired:1];
singleTap.delegate = self;
[myPhotoView addGestureRecognizer:singleTap];
[singleTap release];

This all works fine, but I need to call a method in the PhotoViewController class when the view is tapped as well as in the MyToolBerController class.
When I add another UITapGestureRecognizer in the photoViewController, it overrides the UITapGestureRecognizer added in the superView.

  • 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-15T19:03:34+00:00Added an answer on May 15, 2026 at 7:03 pm

    In your gesture recognizer selector method, pass the information along to the subview. There’s no need to have multiple gesture recognizers for the same gesture. Something like:

    - (IBAction)handleSingleDoubleTap:(UIGestureRecognizer *)sender
    {
        CGPoint tapPoint = [sender locationInView:sender.view.superview];
        UIView *subview = [parentView viewWithTag:100];
        [subview doSomethingWithPoint:tapPoint];
    }
    

    This of course means that your subview that needs to be notified should be given the tag 100 either in Interface Builder or in code when the view controller gets loaded.

    Update based on Jonah’s code:

    So instead of retaining the view, retain the view controller:

    PhotoViewController *photoViewController = [[PhotoViewController alloc] initWithNibName:@"PhotoViewController" bundle:nil];
    self.myPhotoViewController = photoViewController;
    

    Which means you need to declare it this way in the MyToolbarController header:

    @property (nonatomic, retain) PhotoViewController *myPhotoViewController;
    

    Then, when your gesture selector gets called, pass the message along to the view controller you retained. Something like:

    - (IBAction)handleSingleTapFrom:(UIGestureRecognizer *)sender
    {
        CGPoint tapPoint = [sender locationInView:sender.view.superview];
        [myPhotoViewController doSomethingWithPoint:tapPoint];
    }
    

    Of course the -doSomethingWithPoint: method is only for example. You can name and create any method you want that takes any parameter you want to pass in your PhotoViewController.

    Let me know if you need further clarification.

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

Sidebar

Related Questions

I want to answer a phone call. I found the intent android.intent.action.ANSWER but it
I want to call outer class' method getContentPane() from inner Action class. I don't
I want to call MVC actions with parameters location.href = '<%: Url.Action(mAction, mControl, new
I have two classes: Action and MyAction . The latter is declared as: class
Simply scenario -- I have two buttons both of which call the same controller/action.
I am currenting using FW/1 and tracking traffic via the following function call this.wsTraffic.add(action
i have two functions and one of them call the other one. I want
I have two submit buttons which call the same action method. How can I
I want to bind an action to two commands that will be done one
I want call the function startActivity in two ways: First (It works): public class

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.