Buttons not showing in table header / Xcode 7

#1

Hi all,

I’ve read over the text many times, gone through everything, and just can’t understand how to make these buttons show up! I’ve changed the background color of the header, and it correctly shows up on the simulator… so I know the header is being loaded, just can’t seem to make the buttons show up (tried everything I can think of).

Thinking something must’ve changed from Xcode 5 til 7? Anyone else ever had this issue? Thanks!

Screenshot of what’s happening:

ItemsViewController.m code (so you see I’ve got everything wired up correctly):

[code]
#import “ItemsViewController.h”
#import “ItemStore.h”
#import “Item.h”

@interface ItemsViewController ()

@property (nonatomic, strong) IBOutlet UIView *headerView;

@end

@implementation ItemsViewController

-(instancetype)init {

self = [super initWithStyle:UITableViewStylePlain];

if (self) {
    
    for (int i =0 ; i<5 ; i++) {
        
        [[ItemStore sharedStore] createItem];
    }
    
}

return self;

}

  • (UIView *) headerView {

    if (!_headerView) {

      [[NSBundle mainBundle] loadNibNamed:@"HeaderView"
                                    owner:self
                                  options:nil];
    

    }

    return _headerView;
    }

  • (instancetype)initWithStyle:(UITableViewStyle)style {

    return [self init];
    }

  • (IBAction)addNewItem:(id)sender {

}

  • (IBAction)toggleEditingMode:(id)sender {

    if (self.isEditing) {

      //Change text of button to inform user of state
      [sender setTitle:@"Edit" forState: UIControlStateNormal];
      
      //Turn off editing mode
      [self setEditing:NO animated:YES];
    

    }

    else {

      // Change text of button to inform user of state
      [sender setTitle:@"Done" forState: UIControlStateNormal];
      
      // Enter editing mode
      [sender setEditing: YES animated: YES];
    

    }

}

  • (NSInteger) tableView: (UITableView *)tableView
    numberOfRowsInSection:(NSInteger)section {

    return [[[ItemStore sharedStore] allItems] count];
    }

  • (UITableViewCell *) tableView:(UITableView *)tableView
    cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
    reuseIdentifier:@“UITableViewCell”];

    cell.textLabel.text = [[[ItemStore sharedStore] allItems][indexPath.row] description];

    return cell;
    }

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{

return self.headerView;

}

  • (void) viewDidLoad {

    [super viewDidLoad];

    [self.tableView registerClass:[UITableViewCell class]
    forCellReuseIdentifier:@“UITableViewCell”];

    [self.tableView setTableHeaderView:self.headerView];

}

@end[/code]

#2

After a lot of misery and learning, turns out I had to disable the Auto resizing mask like so in ViewdidLoad

Hope this helps someone else!