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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:51:04+00:00 2026-06-18T01:51:04+00:00

I have designed tableView through the storyboard, in one cell i have one button

  • 0

I have designed tableView through the storyboard, in one cell i have one button & one Label.
button is has tag-1 & Label has tag-2 on the storyboard.in cellForRowAtIndexPath i am accessing these like below

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@" i am back in cellForRowAtIndexPath");  

    static NSString *CellIdentifier = nil;
   // UILabel *topicLabel;
    NSInteger rows=indexPath.row;
    NSLog(@"row num=%i",rows);
    if (rows % 2==0)
    {
        CellIdentifier=@"LeftTopicCell";
    }
    else
    {
        CellIdentifier=@"RightTopicCell";

    }

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    UIButton *topicButton=(UIButton *)[cell viewWithTag:1];
    UILabel  *topicScoreLabel=(UILabel *)[cell viewWithTag:2];

    NSString *topicNameLabel=[[NSString alloc]init];

    //some logic processing


            topicNameLabel= topicItem.topicTitle;

            [topicButton setTitle:topicNameLabel forState:UIControlStateNormal];
        [topicButton setTag:indexPath.row ];
            [topicButton setTitle:topicNameLabel forState:UIControlStateHighlighted];
            [topicButton addTarget:self action:@selector(topicButtonSelected:) forControlEvents:UIControlEventTouchDown];

        [topicScoreLabel setText:[NSString stringWithFormat:@"%d/%d",correctAnswers,[answerResults count]]];
    }

    return cell;
}

first time it works fine but when i came back to this viewcontroller, i have reloaded this again, but this time for two rows it works well. but for third rows it returns UIButton instead of UILabel for this line UILabel *topicScoreLabel=(UILabel *)[cell viewWithTag:2]; & because of this it is giving exception “unrecognised selector “[UIButton setText]””;

  • 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-18T01:51:05+00:00Added an answer on June 18, 2026 at 1:51 am

    i got answer ,because i am updating button tag through the setTag method in cellForRowAtIndexPath according to row number, it is setting tag to button as number 2 thats why it returning UIButton

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

Sidebar

Related Questions

I have a tableview with multiple prototype cells that i designed in the storyboard,
I have designed this gui in netBeans which has a canvas , a couple
I have designed one sign-up form,in this form after getting all necessary values I
I have a custom cell for my table view which I have designed using
i have designed an form in that form contain button when i click on
I have a tableview with all cells having a button each. Each button is
I have designed this server to broadcast to all clients when it has to
I have designed my database in such a way that One of my table
I have created a grouped table view & I had a edit button in
I have a simple cell - designed in IB - and with the reuseIdentifier

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.