Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It takes little work to add section headers to your grouped table. Listing 6-1 shows the optional tableView: titleForHeaderInSection: method that titles each section. It’s passed an integer. In return, you supply a title.
|
Code View:
Scroll
/
Show All #define ALPHA_ARRAY [NSArray arrayWithObjects: @"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L", @"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"U", @"V", @"W", @"X", @"Y", @"Z", nil]
// Add a title for each section
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [NSString stringWithFormat:@"Crayon names starting with '%@'", [ALPHA_ARRAY objectAtIndex:section]];
}
|