我有一个TableViewController
,然后单击自定义单元格会将您带到相关的WebViewController
.
我遇到的问题是,当我点击“返回”时WebViewController
中的表视图单元格TableViewController
“跳”。
一旦表格视图开始滚动,它们都会跳回到正确的高度。所以我假设这与高度有关TableViewController
自定义单元格,但我不完全确定。
TableViewController.m
Tried:
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
id model = self.Model[indexPath.row];
if ([model isKindOfClass:[Two self]]) {
return 490; // As of 11/13/14
} else { // 2 other custom cells
return tableView.rowHeight; // return the default height
}
}
还尝试过:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
id model = self.Model[indexPath.row];
if ([model isKindOfClass:[One self]]) {
ListTableViewCell *cellOne = [tableView dequeueReusableCellWithIdentifier:@"1Cell"];
CGFloat heightOne = [cellOne.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return heightOne + 2;
} else if ([model isKindOfClass:[Two self]]) {
ListTableViewCellTwo *cellTwo = [tableView dequeueReusableCellWithIdentifier:@"2Cell"];
CGFloat heightTwo = [cellTwo.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return heightTwo + 400;
} else if ([model isKindOfClass:[Three self]]) {
ListTableViewCellThree *cellThree = [tableView dequeueReusableCellWithIdentifier:@"3Cell"];
CGFloat heightThree = [cellThree.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return heightThree + 2;
} else {
return 300;
}
}
UPDATE:
也尝试过[cell setNeedsUpdateConstraints];
and [cell setNeedsLayout];
.
也尝试过设置estimatedHeight
多个不同的点,并且还添加了Automatic Row Dimension
与此同时进行。
帮助将不胜感激!将发布所需的任何额外信息。谢谢!
我仅支持 iOS 8。我正在使用自动布局和情节提要。
Additional Storyboard info for Custom Cell 2:
故事板限制: