1

I'm using InAppSettingsKit for my app but I'm having problems changing the text color of my section headers in my grouped tableview. I've tried using the following code but it doesn't work:

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        UIView *tempView=[[UIView alloc]initWithFrame:CGRectMake(0,200,300,244)];
        tempView.backgroundColor=[UIColor clearColor];

        UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0,300,44)];
        tempLabel.backgroundColor=[UIColor clearColor]; 
        tempLabel.shadowColor = [UIColor blackColor];
        tempLabel.shadowOffset = CGSizeMake(0,2);
        tempLabel.textColor = [UIColor redColor]; //here u can change the text color of header
        tempLabel.font = [UIFont fontWithName:@"Helvetica" size:fontSizeForHeaders];
        tempLabel.font = [UIFont boldSystemFontOfSize:fontSizeForHeaders];
            tempLabel.text=@"Header Text";

        [tempView addSubview:tempLabel];

        [tempLabel release];
        return tempView;
    }

The InAppSettingsKit code looks like so:

- (NSString *)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section {
    NSString *header = [self.settingsReader titleForSection:section];
    if (0 == header.length) {
        return nil;
    }
    return header;
}

- (UIView *)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section {
    NSString *key  = [self.settingsReader keyForSection:section];
    if ([self.delegate respondsToSelector:@selector(tableView:viewForHeaderForKey:)]) {
        return [self.delegate tableView:_tableView viewForHeaderForKey:key];
    } else {
        return nil;

}
}

How would I implement the first code into their code? I need to change the text color of those titles. Thanks.

Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
0SX
  • 1,252
  • 6
  • 24
  • 47

1 Answers1

1

Implement -tableView:viewForHeaderForKey: in your IASKSettingsDelegate. The implementation would be identical to your -tableView:viewForHeaderInSection: code except that you'd need to check the key to determine the text of the label (if you have multiple headers).

Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
  • thank you for your works. but how can i call "NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];" in "- (UIView *)tableView:(UITableView *)tableView viewForHeaderForKey:(NSString*)key" ? since i dont have "section"? – ThinkChris Mar 05 '12 at 05:34
  • 1
    Indeed, this is a missing piece atm. Your best bet is to return the appropriate title depending on the key (identical to the Key in the plist). Alternatively you could modify the delegate method to include the section. – Ortwin Gentz Mar 05 '12 at 10:55