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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:13:21+00:00 2026-05-31T02:13:21+00:00

I have a project with a custom UITableViewCell (cell.h/.m/.xib) that has 2 labels (labelMain/labelSub),

  • 0

I have a project with a custom UITableViewCell (cell.h/.m/.xib) that has 2 labels (labelMain/labelSub), and 2 buttons on it (buttonName/buttonInfo) linked to 2 actions (showName/showInfo).

What I want to do is be able to access the 2 actions in my projects main viewcontroller so that when showName is pressed, a textfield.text in the viewcontroller (not in the cell) is set to that specific cell’s labelMain.text.

Hope that makes sense. My problem is that if I write the action (showName) in the cell.m, I cannot access the textfield from my main viewcontroller. On the flip side, if I write the action in my viewcontroller, how do I know which button inside which cell was tapped?

Hope this makes sense…

  • 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-31T02:13:23+00:00Added an answer on May 31, 2026 at 2:13 am

    Use tag can identify which button in which cell is being tapped.

    - (UITableViewCell *)tableView:(UITableView *)tableViews cellForRowAtIndexPath:(NSIndexPath *)indexPath {
          //init identifier
          if (cell ==nil)
           {
            //load nib file
           }
        
          buttonName.tag = indexPath.row;
          [buttonName addTarget:self action:@selector(showName:) forControlEvents:UIControlEventTouchUpInside];
    
          buttonInfo.tag = indexPath.row;
          [buttonInfo addTarget:self action:@selector(showInfo:) forControlEvents:UIControlEventTouchUpInside];
    
        }
    }
    
    -(void) showName:(UIButton*)button{
      int row = button.tag; //you know that which row button is tapped
    }
    
    -(void)showInfo:(UIButton*)button{
     int row = button.tag;//you know that which row button is tapped
    }
    

    —————- EDIT ————-

    If you need to know which button is pressed based on row & section, you may try this below. (in cellForRowAtIndexPath: method)

    int tag = (indexPath.row+1)+(indexPath.section*100);
    buttonName.tag = tag;
    

    When button at

    row = 5, section = 0 then tag = 6.

    row = 4, section = 3 then tag = 305.

    row = 0, section = 11 then tag =1101.

    limitation, row cannot be more than 99. and DON’T use positive tag for other view. if you need use tag, try negative. (-1, -9, -100).

    so from here, you can calculate back row & section of indexPath. using this :

    -(NSIndexPath*)getIndexPathFromTag:(NSInteger)tag{
        /* To get indexPath from textfeidl tag,
         TextField tag set = (indexPath.row +1) + (indexPath.section*100) */
        int row =0;
        int section =0;
        for (int i =100; i<tag; i=i+100) {
            section++;
        }
        row = tag - (section*100);
        row-=1;
        return  [NSIndexPath indexPathForRow:row inSection:section];
        
    }
    

    how to use :

    -(void)showInfo:(UIButton*)button{
         NSIndexPath *indexPath = [self getIndexPathFromTag:button.tag];
         int row = indexPath.row;
         int section = indexPath.section;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom HttpModule rewrite engine in an existing web application project that
I have an ASP.NET project which has already some custom fields in it's web.config
I have a project which has several custom descriptors written for the assembly plugin.
I have a project that is using a generic list of a custom class.
I have a project in IAR Workbench that requires a custom build step to
Good Day I have a project that makes use of custom assemblies in the
Assume that I have a project that contains two buttons on it. Each buttons
I have visual studio setup project with a custom RadioButtons dialog. How do I
I have sevevral custom actions as part of an MSI project, defined in vS2008.
I have a custom build target in a visual studio 2008 c# project. Is

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.