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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:41:06+00:00 2026-06-17T00:41:06+00:00

I have a UITableViewController that contains a table, whose cells I wish to add

  • 0

I have a UITableViewController that contains a table, whose cells I wish to add a button to. This is a customized button that will act as a checkbox, with an image that it has for its normal state, and another image that it has when the user selects it. Unfortunately, the image is not changing state whenever I press it, and for some reason, it is also not calling the target method.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    // Configure the cell...
    TestObject *tObject = [myNSMutableArray objectAtIndex:indexPath.row];
    cell.textLabel.text = tObject.testTitle;

    testButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [testButton setFrame:CGRectMake(280, 57, 25, 25)];
    [testButton setImage:[UIImage imageNamed:@"CheckBox1.png"] forState:UIControlStateSelected];
    [testButton setImage:[UIImage imageNamed:@"CheckBox2.png"] forState:UIControlStateNormal];
    [testButton setUserInteractionEnabled:YES];
    [testButton addTarget:self action:@selector(clickOnCheckButton:) forControlEvents:UIControlEventTouchUpInside];

    [cell addSubview:testButton];

    return cell;

}

For the record, I have indeed implemented the method:

-(void)clickOnCheckButton:(id)sender {

    NSLog(@"button has been pressed");
}

and have made sure the spelling is correct, which is why I don’t understand the reason why the method is not being called when the button in each cell is pressed.

The other problem with my table output is that my very first cell does not have a button inside it. All other cells below it however, do.

Can anyone see what I am doing wrong?

Thanks in advance to all who reply.

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

    If you use the cell’s accessoryView property you can set it to a custom view, like your button, and it’s designed to act like a button. You then have the option to use the UITableViewDelegate method – tableView:accessoryButtonTappedForRowWithIndexPath: to control the action.

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

Sidebar

Related Questions

I have a UITableViewController that has a UITableView whose cells have a button attached
I have a UITableViewController that has custom cells that I have customized with my
I have a UITableViewController that displays cells that are just default. Each cell can
I have 8 cells that are being built in my UITableViewController. I would like
I have a UITableView that I want to edit inside of a UITableViewController. This
I have a subclass of UITableViewController. I have code that can add/remove a UISearchBar
I have a UITableViewController that contains a tableView. I want to set its scrollView
I cannot seem to find this anywhere online. I have an add button in
I have a nib that contains two TableViews. The table views are of the
I have a UITableViewController that push a EKEventViewController on selecting a row using this

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.