ios - Tableview Cell 无法正确显示

标签 ios swift xcode uitableview tableview

我的表格 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/

相关文章:

ios - 无法使用自动布局创建 iOS 项目

ios - 在进行最小滚动或点击之前,单元格不会显示在表格 View 中(注意 : nothing happens on a background thread)

ios - 在 Xcode 中确定 iDevice 当前日期 - NSDate

ios - 在 UITableViewCell 中动态布置 subview

swift - 为什么我的 self.init 不会自动填充方便的初始化程序?

ios - Firebase 推送通知仅显示在控制台中,不会在后台加载

ios - 使用observeForSingleEventOfType 崩溃

swift - Swift 语言中的 #ifdef 替换

javascript - 从 Whatsapp 测验代码更改分享数量

ios - Grepping 或过滤 Xcode "Devices"控制台