【发布时间】:2016-09-14 19:31:35
【问题描述】:
我的 UITableView 中有两种类型的单元格 - commonCell 和 expandCell。展开的单元格在点击时展开,显示完整的描述,并且标签会相应地调整自身,即标签高度是动态的。 UITableView snapshot showing cell with attachment opened
以下所有代码都写在里面 - tableView:heightForRowAtIndexPath: 用于展开的单元格:
// Debug area log before changing frame
//Printing description of viewAttachment:
//UIView: 0x7f8f84d8b050; frame = (16 107; 288 20); autoresize = RM+BM; tag = 314; layer = CALayer: 0x7f8f84d7a340
CGFloat height =[[HSHelper sharedInstance] getLabelSizeFortext:help.helpDescription forWidth:labelDescText.frame.size.width WithFont:kFontRobotoRegular(15).height;
height = (height<20.0)? 20.0 + 20: height + 10;
CGFloat heightAttachment = 0.0;
if (help.helpAttachmentName.length != 0) {
heightAttachment = [HSHelper sharedInstance].isiPad ? 35.0 :20.0;
} else {
CGRect framee = viewAttachment.frame;
framee.size.height = 0.0f;
viewAttachment.frame = framee;
}
// Debug area log after changing frame
//Printing description of viewAttachment:
//UIView: 0x7f8f84d8b050; frame = (16 107; 288 0); autoresize = RM+BM; tag = 314; layer = CALayer: 0x7f8f84d7a340
return height + 23.0 + heightAttachment + 34.0;
图片显示问题: UITableView snapshot showing cell without attachment opened
正如您在我的代码中看到的,注释部分显示了在我的调试区域中打印的结果,清楚地显示 viewAttachment 的高度已更改。但是,模拟器快照图像仍然显示没有附加文件的空白区域应该折叠。
我还在情节提要中将 viewAttachment 的高度设置为“
请帮我解决这个奇怪的问题。提前致谢。
【问题讨论】:
-
在此之后您是否重新加载表?
-
当然是@Nitin。我已经试过了。
-
日志显示帧为 (16 107; 288 0)。表示高度为 0。
标签: ios objective-c uitableview uiview collapse