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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:10:16+00:00 2026-05-17T00:10:16+00:00

I have stumbled upon a problem when adding a button to my table view

  • 0

I have stumbled upon a problem when adding a button to my table view cell.

Let me explain after i have added the code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

RadioCustomCell * cell = (RadioCustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[RadioCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        [cell setChannelImage:[UIImage imageNamed:@"p4.png"]];

        UILabel *nowTitle = [UILabel alloc];
        nowTitle.text = @"In My Heart";
        [cell setNowTitle:nowTitle];

        UILabel *nowArtist = [UILabel alloc];
        nowArtist.text = @"Moby";
        [cell setNowArtist:nowArtist];

        UILabel *nextTitle = [UILabel alloc];
        nextTitle.text = @"Only Girl (In The World)";
        [cell setNextTitle:nextTitle];

        UILabel *nextArtist = [UILabel alloc];
        nextArtist.text = @"Rihanna";
        [cell setNextArtist:nextArtist];

        // My button right here
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(6 ,31, 110, 20);
        [button setImage:[UIImage imageNamed:@"radionorge.png"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(touched:) forControlEvents:UIControlEventTouchUpInside];

        [cell.backView addSubview:button];

    }
    return cell;
}

And the “touched”-function for the action for the button.

-(void)touched:(id)Sender {

    // Here i want to get the UILabels for each cell. Such as nowArtist.

}

You see, i want to get the UILabel-texts for each cell at the touched-function.
I know that you must use the Sender as a pointer in some sort of way, but i don’t know how.

  • 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-17T00:10:17+00:00Added an answer on May 17, 2026 at 12:10 am

    First, you’re going to want to set the tag property for each label. Using a #define or const is a good idea, but for simplicity, I’m going to assume you’ll use 1, 2, 3, and 4 for each UILabel in the order they appear in the code.

    This is what you’re action code should look like. (You may need to tweak it a bit.)

    -(void)touched:(id)Sender {
        // Here i want to get the UILabels for each cell. Such as nowArtist.
        if ([sender isKindOfClass:[UIButton class]]) {
            UIButton *button = (UIButton *)sender;
            UIView *contentView = button.superview;
            UIView *viewWithTag1 = [contentView viewWithTag:1];
            if ([viewWithTag1 isKindOfClass:[UILabel class]]) {
                 UILabel *titleLabel = (UILabel *)viewWithTag1;
                 // You now have the title label.
            }
            // Repeat the above for each tag.
    }
    

    One observation: You’re leaking a LOT of objects in you’re code. You don’t need to alloc a bunch of new labels each time you update a cell. Just use something like:

    cell.nowTitle.text = @"In My Heart";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently stumbled upon a problem with selecting relationship details from a 1
I have stumbled upon a problem when calling a nested Async which happens to
I stumbled upon a curious problem with MFC. I have a Dialog where I
Im quite new to Java and i have stumbled upon the following problem. Im
I have stumbled upon a problem. I have two different select fields. Each of
I have stumbled upon an interesting problem/bug that I eventually solved, but the solution
I have stumbled upon a problem when creating a program of mine. I have
Coming from Question which was answered really quick, I have stumbled upon upgraded problem.
I have stumbled upon the following F77 yacc grammar: http://yaxx.cvs.sourceforge.net/viewvc/yaxx/yaxx/fortran/fortran.y?revision=1.3&view=markup . How can I
I'm pretty new in iphone programming and have stumbled upon this issue which I

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.