views:

18

answers:

1

Basically I want to re-style UITableView(Controller). Each cell will have a picture as a background and such. this tableview will be used throughout the app thats why I want to subclass it, because I want to be able to define the style once and then reuse it everywhere, but still be able to change things per view. For instance, I'd like every cell to have the same blue background and a specific font, but I might want to change the font in one view, or make the cell taller/shorter. You get the idea.

Can I subclass UITableViewController and create the style in the methods in that? Then subclass MyCustomUITableViewController when I want to create a table view? Or would it better to subclass UITableView and then [self.view addSubview:(MyCustomTableView *)tableVie]?

Thanks

Tom

+1  A: 

You will probably want to subclass UITableViewController to define relevant UITableViewDelegate methods, but I think that the real work will be in subclassing UITableViewCell to get the look that you want.

UITableViewCell is a UIView, so it can have a background color and it can contain a UILabel, for example.

Your -tableView:cellForRowAtIndexPath: will need to instantiate your UITableViewCell subclass (or load it from a nib) - and then configure it appropriately. I.e., setting text, image, font, etc.

Hope this helps.

westsider