Change uitablelview properties on subclass in viewdownload in cocoa?

I am following a tutorial that manipulates a uitableview with a uiviewcontroller to create vibrant styled cells.

I was wondering if the same could be done with a class that subclasses uitablewcontroller instead of uiviewcontroller. 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 subclass of uitableview. I tried to do

    self.rowHeight = 50;

      

But it 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

0


a source to share


2 answers


Cocoa Design Patterns encourage the use of a controller object to customize views, but there is no reason you cannot subclass as you describe, especially if you need to add functionality that cannot be done in any other way, you can use properties and methods as you describe, so the problem is somewhere else. What method do you use to subclass to assign the row height? Have you checked in the debugger to make sure your subclass is allocated instead of the normal table view?



0


a source


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

In viewDidLoad you can set whatever table properties you like, except style (style must be set in initializer or in IB)



- (void)viewDidLoad{

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

//etc...

}

      

0


a source







All Articles