views:

75

answers:

1

I have added a UITableView in IB and set the delegate and datasource and all is working well. What I wanted to do next was change the separator color, but the only way I could find to do this was to add the method to one of the delegate callbacks, is there a better place I should put this?

I don't have this at the moment but I was thinking that maybe I need to add an iVar from my controller that I can link to the UITableView in IB and then set separator color in the viewDidload?

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView setSeparatorColor:[UIColor blackColor]];
    return 65;
}
+2  A: 
- (void)viewDidLoad
{
   [self.tableView setSeparatorColor:[UIColor myColor]];
}

I hope that helps - you'll need the self. to access it, remember.

Helen
Hi Helen, does that access it without the need to add a @property, it looks like it does?
fuzzygoat
This is true. You are subclassing UITableViewController, which declares it as a property. It therefore inherits the accessor/setter methods of the superclass, so you can set it accordingly. However, you cannot access the instance variable directly (probably a good thing). The reason why you can set it in a delegate method is because it is a parameter to the method called.
Helen