tags:

views:

19

answers:

1

hi all i have so confused to make an image in the table's header section , and i have make put the image in the cell of table but i cannot understand how to make put image in the section part of table . here is my code of that method ..

  • (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

    if (section == 0) {

// return @"Alpahbets"; With String

    UILabel *alphabet = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 100)];
    alphabet.text = @"Alphabet";
    return alphabet.text;





} if (section == 1) {

// return @"Roman"; with String UILabel *roman = [[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 100)]; roman.text = @"Roman"; return roman.text;

} else {

//  return @"Digits"; With String
    UILabel *digit = [[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 100)];
    digit.text = @"Digit";
    return digit.text;

}

}

+1  A: 

You're using the wrong Delegate method. That delegate method, from the UITableViewDataSource only allows you to provide a new text string for the default section header types.

To add an image to the section headers you want to take a look at the UITableViewDelete methods

Modifying the Header and Footer of Sections
– tableView:viewForHeaderInSection:
– tableView:viewForFooterInSection:
– tableView:heightForHeaderInSection:
– tableView:heightForFooterInSection:

Using these you can provide a new view (rather than just the text) for a header of a section.

JonB