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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:43:10+00:00 2026-06-10T04:43:10+00:00

I have added UIButton in UITableViewCells . I have when the user clicks the

  • 0

I have added UIButton in UITableViewCells. I have when the user clicks the button we have get the indexpath to use the values from NSMutableArray. I have used the below to get the current IndexPath,

[getMeButton addTarget:self action:@selector(resendTheErrorMessage:) forControlEvents:UIControlEventTouchUpInside];

-(void) resendTheErrorMessage:(id)sender 
{
   NSLog(@"SEnder: %@", sender);
   //NSLog(@"Index Path : %@", indexpath);
}

Can anyone please help me to pass current indexpath UIButton's @selector. Thanks in advance.

EDIT:

This is the output I got from NSLog()

<UIButton: 0x864d420; frame = (225 31; 95 16); opaque = NO; tag = 105; layer = <CALayer: 0x864d570>>
  • 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-10T04:43:11+00:00Added an answer on June 10, 2026 at 4:43 am

    Add Your UIButton Like this

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn setFrame:CGRectMake(10.0, 2.0, 140.0, 40.0)];
    [btn setTitle:@"ButtonTitle" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [btn setTag:indexPath.row];
    [cell.contentView addSubview:btn];
    

    And then get its tag number –

    -(void)buttonClicked:(id)sender
    {
        NSLog(@"tag number is = %d",[sender tag]);
        //In this case the tag number of button will be same as your cellIndex.
       // You can make your cell from this.
    
       NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0];
       UITableViewCell *cell = [tblView cellForRowAtIndexPath:indexPath];
    }
    

    Note: Above solution will work when your tableView has only 1 section. If your tableView has more than one section either you should know your section index or go for below methods.

    Alternative:1

    UIView *contentView = (UIView *)[sender superview];
    UITableViewCell *cell = (UITableViewCell *)[contentView superview];
    NSIndexPath *indexPath = [tblView indexPathForCell:cell];
    

    Alternative:2

    CGPoint touchPoint = [sender convertPoint:CGPointZero toView:tblView];
    NSIndexPath *indexPath = [tblView indexPathForRowAtPoint:touchPoint];
    UITableViewCell *cell = [tblView cellForRowAtIndexPath:indexPath];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom UIButton with UILabel added as subview. Button perform given selector
I have added a TextField to a UICell in order to allow a user
I have added UIButton and UITextView as subviews to my view programmatically. notesDescriptionView =
I am trying to add the UIButton to UIScrollView . I have added the
i have added a UIViewController's view and a button to scrollview as subview...now how
I have a problem where the button's I have added to .xib file are
I have a custom UIButton added as subview to a UIView subclass. In my
I have a UILongPressGestureRecognizer added to a UIButton. When I press the UIButton it
I have a UIButton added to a UITableViewCell In order to reduce code redundancy,
I have a UIButton that is added to each UITableViewCell (except for 2 cells)

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.