tags:

views:

34

answers:

2

Hi,

I am working on a custom tableviewcell and trying to increase its height. I dont want to do it from my viewcontroller. Can someone please help me?

Thanks

A: 

I'm afraid you have to do it from your controller in the tableView:heightForRowAtIndexPath:. There is no other way to do it. :(

Thomas Børlum
@Thomas, you got the right idea, but the wrong method name. :P
Jacob Relkin
Gah, going my memory here :) Now I'll have to actually check it. Thanks for the heads-up.
Thomas Børlum
+2  A: 

You actually need to do it from your UITableViewDelegate.

What you can do though, is use UITableView's cellForRowAtIndexPath method to get the actual cell and call isKindOfClass: on it, and if it matches the type of your custom cell, you're golden.

Implement the tableView:heightForRowAtIndexPath: method and return the desired height for the specified row:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
   if([cell isKindOfClass:[YourCustomCell class]]) return someHeight;
   return 44.0;
}
Jacob Relkin
but i wanted to make a custom cell which can be used straightaway without making any changes in its design..... is it possible doing it without using delegate method of tableview?
pankaj
@pankaj - Nope.
Jacob Relkin