何らかの理由で、セルUITableViewCell
の高さがゼロになるように計算しています。
これが私が現在持っているものです:
- (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
}
heightOne
ブレークポイントで値が何であるかを確認するときにゼロを返す理由がわかりませんheightOne
。
私はオートレイアウトを使用しています。
何か案は?ありがとう!必要に応じて追加のコードを投稿します、ありがとう!