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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:45:00+00:00 2026-06-17T01:45:00+00:00

I have a UITableViewController that has a tableView. Each cell has a button that

  • 0

I have a UITableViewController that has a tableView. Each cell has a button that can be selected/deslected like a checkbox, and the method that does this is working fine. I would like to have another method that gets called by a button in the tableheaderview that is able to iterate through this list and select all of the buttons in one fell swoop. The irony is that I am able to perform the iteration, but can’t seem to call the method that selects/deselects the button.

Here is my relevant code:

//This is my method does the iteration
- (void) startWizard {

    NSLog(@"Did it select?");

    for (int i = 0; i < [self.tableView numberOfSections]; i++) {
        for (int j = 0; j < [self.tableView numberOfRowsInSection:i]; j++) {
            NSUInteger ints[2] = {i,j};
            NSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:ints length:2];
            UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
            //Here is my code to call the method that selects/deselects
            [self buttonTouched:nil];



        }
    }
}

and here is the method that does the actual select/deselect of each individual button (and works fine):

-(void)buttonTouched:(id)sender
{
    UIButton *btn = (UIButton *)sender;

    if( [[btn imageForState:UIControlStateNormal] isEqual:[UIImage imageNamed:@"CheckBox1.png"]])
    {
        [btn setImage:[UIImage imageNamed:@"CheckBox2.png"] forState:UIControlStateNormal];
        // other statements
    }
    else
    {
        [btn setImage:[UIImage imageNamed:@"CheckBox1.png"] forState:UIControlStateNormal];
        // other statements
    }

}

The button in each cell has been added to that cell as its accesseryView as follows:

[cell setAccessoryView:testButton];

Can anyone see what I am doing wrong, and how I can fix this?

  • 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-17T01:45:01+00:00Added an answer on June 17, 2026 at 1:45 am

    When you call in the loop [self buttonTouched:nil]; you call the method buttonTouched with nil as value for sender. Therefore, the first line in buttonTouched sets btn to nil and the rest of the methods operates on the nil button.
    Either find a way to pass the actual button object to buttonTouched or pass the indexPath an d find the correct button by that.

    • 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 displays cells that are just default. Each cell can
I have a UITableViewController that has a tableView. To this tableView, I would like
I have a UITableViewController that has a UITableView whose cells have a button attached
I have an iPad app that has a UITableViewController that implements the NSFetchedResultsControllerDelegate .
I have 8 cells that are being built in my UITableViewController. I would like
I have a subclass of UITableViewController. I have code that can add/remove a UISearchBar
My application has a view controller that extends UITableViewController . The initialization method looks
I'm trying to link cells from an UITableViewController to UIViewController, but each cell has
I have a UITableViewController which has a UIView* called errorView that is used to
I have a UITableViewController that has a UISearchbar in its header view. When the

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.