Reputation: 8358
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
Upvotes: 1
Views: 430
Reputation: 926
I'm afraid you have to do it from your controller in the tableView:heightForRowAtIndexPath:
. There is no other way to do it. :(
Upvotes: 0
Reputation: 163268
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;
}
Upvotes: 4