views:

163

answers:

2

I've been following a tutorial that manipulates a uitableview from a uiviewcontroller to generate nicely styled cells.

I was wondering is it possible to do same to a class that subclasses uitablewcontroller instead of uiviewcontroller. The user uses code like:

    tableView.rowHeight = 50;
tableView.backgroundColor = [UIColor clearColor];

In the viewdidload method. I would like to do the same but again in a uitableview sub class. I tried to do

    self.rowHeight = 50;

But this didn't work. Does anyone know how I can implement this?

Thanks a million!

This is the actual tutorial site: http://blog.atrexis.com/index.cfm/2009/1/6/iPhone--Customize-the-UITableCellView

A: 

The Cocoa design patterns encourage using a controller object to configure views, but there's no reason why you can't subclass like you're describing, especially if you need to add functionality that can't be done any other way. You can use properties and methods just how you're describing, so there's a problem somewhere else. What method are you subclassing to assign the row height? Have you checked in the debugger to make sure your subclass is being allocated instead of a regular table view?

Marc Charbonneau
when i do self.rowHeight = 50; in the uitableviewcontroller class i get the error request for member rowheight in something not a structure or union. Are you sure this the right way to do this in this type of controller class?
Buffernet
Sorry, I thought you meant you're subclassing the table view itself. For the controller you'd call self.tableView.rowHeight to access the property.
Marc Charbonneau
A: 

A UITableViewController IS a subclass of UIViewController. The only diffference is that it conforms to the UITableViewDelegateDataSource and UITableViewDelegate protocols and it has an additional instance variable: tablview.

In viewDidLoad, you can set any table properties you like except for style (style has to be set in the initializer or in IB)

- (void)viewDidLoad{

   [[self tableView] setRowHeight:kCellHeight];
   [[self tableView] setTableHeaderView:myView];

//etc...

}
Corey Floyd