IOS heightForRowAtIndexPath, setting height for empty cells
i am setting the heightForRowAtIndexPath like this:
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
/* Contains the string */
NSString *allStrings = [self convertMainData:indexPath];
UIFont *cellFont = [UIFont fontWithName:@"Helvetica" size:17.0];
CGSize constraintSize = CGSizeMake(280.0f, MAXFLOAT);
CGSize labelSize = [allStrings sizeWithFont:cellFont
constrainedToSize:constraintSize
lineBreakMode:NSLineBreakByWordWrapping];
return labelSize.height + 20;
}
This gets called when the table is not empty, and the size gets calculated
correctly, now the issue is that if there is data in the Table, all the
cells get their height changed:
http://img716.imageshack.us/img716/3025/yrgt.png
I have tried checking for this in the delegate method
if([tableview cellForRowAtIndexPath:IndexPath] == nil)
return 20;
But this returns an error, i have also tried wrapping it in != nil, but
that has no effect, so how do i leave the empty rows at the default height
?
No comments:
Post a Comment