I set height for each UITableViewCell in
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
I need to get each UITableViewCell's height in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
because I need to addSubView in different cells.
I've tried to use cell.frame
& cell.bounds
& cell.contentView.frame
, but the height hasn't changed.
This may be too late, but you can use the delegate method:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
CGRect cellSize = cell.frame;
}
Hope it helps anyone, Let me know if I missed out something. :)
I solved this way:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
// create object
id myObj = [_arrayEvents objectAtIndex:indexPath.row];
// create static identifier
static NSString * myIdentifier = @"Cell";
// create static UITableViewCell
static UITableViewCell * cell;
// create cell with object
cell = [self buildCell:myIdentifier tableView:tableView obj: myObj];
return cell.contentView.frame.size.height;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With