I need to configure the header section of the UITableViewController , where a different header text is returned for each section (getting data from the data source as well). This is accomplished using the following:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { NSArray *temp = [listOfMBeans allKeys]; DLog(@"MBean details: %@", temp); NSString *title = [temp objectAtIndex:section]; DLog(@"Header Title: %@", title); return title; };
This works well, and I see the expected result. However, I also need to change the font size of the text and, looking at similar questions, I implemented the following:
- (UIView *) tableview:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { DLog(@"Custom Header Section Title being set"); UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)] autorelease]; UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)] autorelease]; label.text = [tableView.dataSource tableView:tableView titleForHeaderInSection:section]; label.backgroundColor = [UIColor clearColor]; label.font = [UIFont boldSystemFontOfSize:14]; [headerView addSubview:label]; return headerView; } - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 44.0; }
However, it seems that the code is never called. I realized that the UITableViewController sets the default by itself as a delegate, but it seems like I'm wrong.
UITableViewController is created this way (as part of hierarchical data):
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ProjectDetails *detailViewController = [[ProjectDetails alloc] initWithStyle:UITableViewStyleGrouped]; detailViewController.project = [listOfMetrics objectAtIndex:indexPath.row];
What changes should I make for this to work? Thanks.
source share