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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:06:14+00:00 2026-06-11T11:06:14+00:00

I have the following IBAction method in my code. -(IBAction)handleSingleTap:(id)sender { // need to

  • 0

I have the following IBAction method in my code.

-(IBAction)handleSingleTap:(id)sender
{
    // need to recognize the called object from here (sender)
}


UIView *viewRow = [[UIView alloc] initWithFrame:CGRectMake(20, y, 270, 60)];
// Add action event to viewRow
UITapGestureRecognizer *singleFingerTap = 
[[UITapGestureRecognizer alloc] initWithTarget:self 
                                        action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];
[singleFingerTap release];
//
UILabel *infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(5,30, 100, 20)];
infoLabel.text = @"AAAANNNNVVVVVVGGGGGG";
//[viewRow addSubview:infoLabel];
viewRow.backgroundColor = [UIColor whiteColor];

// display the seperator line 
UILabel *seperatorLablel = [[UILabel alloc] initWithFrame:CGRectMake(0,45, 270, 20)];
seperatorLablel.text = @" ___________________________";
[viewRow addSubview:seperatorLablel];
[scrollview addSubview:viewRow];

How to call the IBAction method while allowing it to receive the caller object of that method?

  • 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-11T11:06:15+00:00Added an answer on June 11, 2026 at 11:06 am

    The method signature is common to gesture recognizer and UIControls. Both will work without warning or error. To determine the sender, first determine the type…

    - (IBAction)handleSingleTap:(id)sender
    {
    // need to recognize the called object from here (sender)
        if ([sender isKindOfClass:[UIGestureRecognizer self]]) {
            // it's a gesture recognizer.  we can cast it and use it like this
            UITapGestureRecognizer *tapGR = (UITapGestureRecognizer *)sender;
            NSLog(@"the sending view is %@", tapGR.view);
        } else if ([sender isKindOfClass:[UIButton self]]) {
            // it's a button
            UIButton *button = (UIButton *)sender;
            button.selected = YES;
        }
        // and so on ...
    }
    

    To call it, call it directly, let a UIControl it’s connected to call it, or let the gesture recognizer call it. They’ll all work.

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

Sidebar

Related Questions

I have created the following POST method via objective-C -(IBAction) postLocation: (id) sender{ NSString
I have the following IBAction set up: #define FAVORITES_KEY @GraphViewController.Favorites - (IBAction)addToFavorites:(id)sender { NSUserDefaults
In my view I have a button, which is hooked to this method: -(IBAction)showStore:(id)sender
I have the following code to fetch the data from URL, store it in
The book I'm currently reading has me write the following code : -(IBAction)displaySomeText:(id)sender {
I have a viewController containing the following method: - (IBAction) playMovie { NSURL *url
I have following code in initialization im = imread('Image02.tif'); figure(); imagesc(im); colormap(gray); [hImage hfig
I have following SQL statementL: select DATE(bla), count(*) from tableA group by DATE(bla) UNION
I have a working code from a tutorial but don't understand it completely. Situation:
I have the following method for getting the AddressBook contacts: - (void) scanAddressBook {

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.