Reputation: 181
I created a new Storyboard app, created an IBOutlet for my table, implemented the two table delegates.
@interface FirstViewController () <UITableViewDelegate,UITableViewDataSource>.
I also implemented the optional selector, "headerViewForSection":
- (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section
{
NSLog(@"called");
//UITableViewHeaderFooterView* header =[self.testTable headerViewForSection:0];
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 20)];
label.text = @"toast";
label.font = [UIFont fontWithName:@"Arial" size:6];
//[header addSubview:label];
return label;
}
unfortunately, I never get a "called" in the console. I also tried to call this manually, but no success on that one.
Why isn't the function get called?
P.S, I added that in the constructor:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_testTable.delegate = self;
_testTable.dataSource = self;
}
so I specified the delegate, I have no why why it's not working.
Upvotes: 2
Views: 1948
Reputation: 77661
That method is part of UITableView
and is an internal method that the UIViewController
doesn't need to go anywhere near.
I believe what you are looking for is the method...
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
which is part of UITableViewDelegate
.
Upvotes: 10