I was looking to set up my cell heights dynamically based off of the value that you set the custom cell in Interface Builder. This did not work out so I have moved on and found this method in Apples docs that can be used to set the cell height – tableView:heightForRowAtIndexPath:
However I am not sure if I am using it correctly as none of my tableviewcells are adjusting their height they all stay the same standard size. This is the code I am using here.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Set cell height
[self tableView:tableView heightForRowAtIndexPath:indexPath];
// Configure the cell using custom cell
[[NSBundle mainBundle] loadNibNamed:@"CustomcellA" owner:self options:nil];
cell = customcellA; // customcellA getters and setters are set up in .h
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 44;
}
any help would be greatly appreciated
lets say the third cell is twice as height:
This method will be called by the tableView.
You shouldn’t do this:
It is up to you, how you ensure, that the right cell’s indexPath is identified for other sizes.
General Rule:
If you implement the method of a delegate protocol, you will never call it yourself. Only the object of the class, that has a delegate conforming to a protocol, will call the delegate methods.