I have UITableViewCell
s that the height of my cell is calculating to be zero for some reason.
Here's what I currently have:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
id model = self.Model[indexPath.row];
if ([model isKindOfClass:[FR self]]) {
ListTableViewCell *cellOne = [tableView dequeueReusableCellWithIdentifier:@"1Cell" forIndexPath:indexPath];
if (!cellOne) {
cellOne = [[ListTableViewCell alloc] init];
FR *fD = (FR *)model;
NSString *title = [NSString stringWithFormat:@"%@", fD.title];
NSString *dateString = [self timeSincePublished:fD.pubDate];
NSString *description = [self removeHTMLTags:fD.description];
NSString *link = [NSString stringWithFormat:@"%@", fD.link];
cellOne.labelHeadline.text = title;
cellOne.labelDescription.text = description;
cellOne.labelPublished.text = dateString;
}
// Make sure the cell's frame is updated
[cellOne setNeedsLayout];
[cellOne layoutIfNeeded];
CGFloat heightOne = [cellOne.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return heightOne + 2;
} else if ([model isKindOfClass:[D self]]) {
// more code
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
id model = self.Model[indexPath.row];
if ([model isKindOfClass:[FR self]]) {
FR *fD = (FR *)model;
ListTableViewCell *1Cell = [tableView dequeueReusableCellWithIdentifier:@"1Cell"];
if (!1Cell) {
1Cell = [[ListTableViewCell alloc] init];
FR *fD = (FR *)model;
NSString *title = [NSString stringWithFormat:@"%@", fD.title];
NSString *dateString = [self timeSincePublished:fD.pubDate];
NSString *description = [self removeHTMLTags:fD.description];
1Cell.labelHeadline.text = title;
1Cell.labelDescription.text = description;
1Cell.labelPublished.text = dateString;
}
return 1Cell;
}
// more code
}
I'm not sure why heightOne
is returning zero when I breakpoint to see what value heightOne
is.
I'm using AutoLayout.
Any ideas? Thanks! Will post extra code if needed, thanks!