ios - 不应用表格 View 单元格高度

标签 ios swift uitableview

虽然我专门为 View 设置了高度,但 View 仍然被切断。原型(prototype)单元格 View 高度已设置为 300,内容 View 和 ImageView 也设置为(稍小)。

知道为什么吗?谢谢。

以下是屏幕截图:

app

Height configuration

最佳答案

由于您使用的是原型(prototype)单元,我假设您使用动态单元。

UITableView 的行高属性始终会覆盖动态单元格的单元格内容高度。因此,实现相应的委托(delegate)方法 heightForRowAtIndexPath: 或通过设置 UITableView 的行高来设置 Storyboard 中的行高。

Swift 3 委托(delegate)方法:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return 300.0;
} 

关于ios - 不应用表格 View 单元格高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40082487/

相关文章:

objective-c - NSDate 和时区差异

ios - 如何在swift 3中制作多色标签栏

ios - 如何从 Firebase 发送 OTP(一次性密码)

ios - 当单元格的元素的框架改变时更新 tableView

ios - 第一响应者在 UISearchBar 上进行平移手势

ios - 设置导航栏按钮的目标

iphone - 滚动时 UITableviewCell 问题

iphone - 重画一个UITableView

swift - 使用 SwiftUI 时调用 "viewDidLoad"时如何运行函数

ios - UItableViewCell 重复