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

  • Home
  • SEARCH
  • 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 9099143
In Process

The Archive Base Latest Questions

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

I have a UITableViewController that has a tableView. To this tableView, I would like

  • 0

I have a UITableViewController that has a tableView. To this tableView, I would like to add both a label as well as a button but unfortunately, I am only able to add one or the other.

Here is my code that I am working with:

- (void) viewDidLoad {

    [super viewDidLoad];

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

    selectAllLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 300, 40)];
    [selectAllLabel setTextColor:[UIColor blackColor]];
    [selectAllLabel setBackgroundColor:[UIColor clearColor]];
    [selectAllLabel setText:@"Select All"];

    self.tableView.tableHeaderView = selectAllButton;
    self.tableView.tableHeaderView = selectAllLabel;

}

When I run the above method, I am only able to see my label which tells me it is replacing the button. Is there a way for me to get both elements to appear in the tableheaderview?

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

    Create a UIView, add your button & label to it as subviews, than make that view your self.tableview.tableHeaderView

    ...your code
    UIView *headerView = [UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, selectAllButton.frame.size.height + selectAllLabel.frame.size.height)];
    
    [headerView addSubview:selectAllButton];
    [headerView selectAllLabel];
    
    self.tableView.tableHeaderView = headerView;
    

    When you init your button & label be sure to change the frame as they will be based on the UIView

    • 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 tableView. Each cell has a button that
I have 8 cells that are being built in my UITableViewController. I would like
I have an iPad app that has a UITableViewController that implements the NSFetchedResultsControllerDelegate .
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 table, whose cells I wish to add
I'm not sure what is going on but I have a list that has
I have this code to set the background image of the UITableViewController: self.tableView.backgroundColor =
I have a UITableViewController which has a UIView* called errorView that is used to
I have a UITableViewController that has a background image. I am setting the image

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.