views:

439

answers:

4

I previously used the following code for changing the size of my cells which use a custom tableviewcell

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 61;
}

However I've created a new one on a different view and the above code is never being called.

The TableViewCell is actually a control on a more generic view however all the other similar methods CellForRow etc are

A: 

Make sure you've set your class as the delegate for the table view, in addition to the dataSource. They are two separate protocols, and this is easy to overlook.

Alex
It is set to datasrouce and delegate already, I dont understand how didSelectRowAtIndexPath, cellForRowAtIndexPath etc work but this one doesnt
tigermain
A: 

Seems I needed this as well

- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier {

    CGRect CellFrame = CGRectMake(0, 0, 300, 60);

    UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease];

    return cell;
}
tigermain
A: 

Also, you can accomplish the same thing (I think) in IB by tweaking the values on the UITableView (not the UITableViewCell).

Genericrich
A: 

heightForRowAtIndexPath is only a UITableView delegate method, not a UITableViewCell method.

So you'd have that code in your delegate class, not in the table cell code.

Kendall Helmstetter Gelner
Thanks for that but it definately was in the correct place
tigermain
If it's never called how can you say it was in the right place? Only your getCellContentView will ever be called, and that's not the right way to do what you are trying to do (you've basically created a UITableViewCell inside of a UITableViewCell for no reason!)
Kendall Helmstetter Gelner