[英]Tableview Cell size not changing? Swift
I dragged an dropped a table view Controller from the object library and changed the cell's row height to 300.However , when I run it in the simulator , the cell remains the same standard size.Why is this? 我从对象库拖动一个表格视图控制器,并将单元格的行高改为300.但是,当我在模拟器中运行它时,单元格保持相同的标准尺寸。为什么这样?
You can set custom row height example add ; 您可以设置自定义行高示例添加;
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return 100.0;//Your custom row height
}
Make sure you have given all the constraints in the cell . 确保您已在单元格中给出所有约束。 They have to be connected from top to bottom. 它们必须从上到下连接。
Make sure that the class of content view inside the custom cell is UIView .(I have done the same mistake ) 确保自定义单元格中的内容视图类是UIView。(我犯了同样的错误)
press content view -> see identity inspector on right -> class should be UI view . 按内容视图 - >查看右侧的身份检查器 - >类应该是UI视图。
使用tableview的委托并设置heightforrowatindexpath方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.