I follow here to add UITableView header, just create a View which include two buttons, however, cannot see two buttons when I run the app.
two overriden functions are:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 60.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *vw = [tableView dequeueReusableCellWithIdentifier:@"HeaderCell"];
return vw;
}
Note: the target ios: 11.4, xcode is 9.4.1, objective-c
========================================= rest code of ViewController.m
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithStyle:UITableViewStylePlain];
if (self) {
for (int i = 0; i < 5; i++) {
[[BNRItemStore sharedStore] createItem];
}
}
return self;
}
- (IBAction)addNewItem:(id)sender
{
}
- (IBAction)toggleEditingMode:(id)sender
{
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath];
BNRItem *item = [BNRItemStore sharedStore].allItems[indexPath.row];
cell.textLabel.text = item.description;
return cell;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
//[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"HeaderCell"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [BNRItemStore sharedStore].allItems.count;
}