我的表格 View 单元格无法正确显示。我不知道问题出在哪里。当我启动模拟器时,它会显示:Simulator.我已经使用了 Contraints,并且我确信 Contraints 是正确的。这是它需要的样子:How it must look like.请帮忙!
最佳答案
将这些添加到您的代码中
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 80.0
}
如果你有多个高度然后像这样放置条件
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
if(indexPath.section == 0){
return 50
}else{
retrn 120
}
}
或者使用自动尺寸,根据其内容自动调整每个单元格的大小:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
关于ios - Tableview Cell 无法正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48705860/