Hmmm...
I don't know if viewDidLoad will help since i'm adding new sections with the '+' button, dynamically. As i've posted before here is the code where i setup my header view. Is there some headerView event that i could use?
- (void)viewDidLoad {
[super viewDidLoad];
// Set up the edit and add buttons.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
AppDelegate_Shared *appDelegate = [[UIApplication sharedApplication] delegate];
self.managedObjectContext = [appDelegate managedObjectContext];
// Create a class definition for MyEntity
SCClassDefinition *myEntityClassDef =
[SCClassDefinition definitionWithEntityName:@"MyEntity"
withManagedObjectContext:self.managedObjectContext
withPropertyNames: [NSArray arrayWithObjects:@"prop1",@"prop2", nil]];
// Instantiate the tabel model
tableModel = [[SCArrayOfObjectsModel alloc] initWithTableView:self.tableView withViewController:self
withEntityClassDefinition:myEntityClassDef];
tableModel.addButtonItem = self.navigationItem.rightBarButtonItem;
tableModel.autoSortSections = TRUE;
}
- (void)tableViewModel:(SCTableViewModel *) tableViewModel willConfigureCell:(SCTableViewCell *) cell forRowAtIndexPath:(NSIndexPath *) indexPath
{
SCTableViewSection *section = [tableViewModel sectionAtIndex:0];
section.headerHeight = 50;
CustomHeader *header = [[[CustomHeader alloc] init] autorelease];
header.lightColor = [UIColor colorWithRed:147.0/255.0 green:105.0/255.0 blue:216.0/255.0 alpha:1.0];
header.darkColor = [UIColor colorWithRed:72.0/255.0 green:22.0/255.0 blue:137.0/255.0 alpha:1.0];
section.headerView = header;
}
- (NSString *)tableViewModel:(SCArrayOfItemsModel *)tableViewModel sectionHeaderTitleForItem:(NSObject *)item AtIndex:(NSUInteger)index
{
// Cast not technically neccessary, done just for clarity
MyEntity *managedObject = (MyEntity *)item;
NSString *objectName = managedObject.somewhere.street;
// Return first charcter of objectName
return [[objectName substringToIndex:1] uppercaseString];
}