views:

21

answers:

2

I set my tabe view to use UITableViewStyleGrouped in IB and the cells look fine, but the section headers still look like they are in UITableViewStylePlain. They are over on the left and position does not not match with cells and they do not scroll when I scroll the cells in the view.

I used

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
return [NSArray arrayWithObjects:@"Cats",@"Area",nil];}

to set section titles.

Cheers, Grant

A: 

According to the documentation for sectionIndexTitlesForTableView, it returns

An array of strings that serve as the title of sections in the table view and appear in the index list on the right side of the table view. The table view must be in the plain style (UITableViewStylePlain). For example, for an alphabetized list, you could return an array containing strings “A” through “Z”.

What you're looking for, I think, is tableView:titleForHeaderInSection:.

Robot K
+1  A: 

Try implementing the - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section method of the UIDataSource protocol instead.

The sectionIndexTitlesForTableView: is for the index on the right-hand side of your table.

Also, have you implemented - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section of the UITableViewDelegate ? If so, you may want to try without it.

DarkDust
Thanks that was it. I hadn't made a view but thanks for the caution.
Grant M