- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在一个 ViewController 中有 2 个 tableview。两个表格 View 的单元格高度不同。
在第一个表格 View 中,我通过 heightForRowAt
委托(delegate)方法进行计算,因为在该表格中,单元格的内容是静态的。第二个是通过 estimatedHeightForRowAt
委托(delegate)方法,因为在该表中,单元格的内容是文本(可能很小或很大)。
所以问题是第二个 tableview 的单元格高度固定为 58。在显示大文本时不会增加。
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if tableView == tblHistory{
let h = ((tableView.frame.size.width - 16) * 7 / 5) + 74
return h
}
else{
return 58
}
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
if tableView == tblHistory{
let h = ((tableView.frame.size.width - 16) * 7 / 5) + 74
return h
}
else{
return 58
}
}
注意:我已正确设置所有约束以根据文本调整单元格高度。
最佳答案
the problem is the height of text cell fixed. That is not increasing while large text display.
在 Storyboard的单元格内,您确实必须完美地约束。
真的有很多东西要知道。您必须显示(屏幕截图)单元格的 Storyboard ,并显示链接 UILabel
和其他项目的所有垂直约束。
一般来说,您不应“固定”UILabel 的高度,或包含 UILabel 的整体“链”。如果你这样做正确,它的隐式高度将起作用。
关于ios - iOS 中的 HeightForRowAt 和 estimatedHeightForRowAt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52034429/
使用此代码,我根据数组中的项目数设置单元格的自动尺寸。它可以工作,但是当我使用另一个 viewController 添加一些新项目然后返回到此时,即使数组数量增加,高度也不会更新。 我在viewDid
像往常一样,我尝试使用以下代码向某些单元格添加一些自定义高度值: func tableView(_ tableView: UITableView, heightForRowAt indexPath:
我正在开发一个电子商务应用程序,但在尝试设置特定行的高度时遇到了问题。当我选择类别时,表格会重新加载,并且根据我选择的类别,或多或少的行会通过 api。 因此,使用此设置,当我选择一个特定类别时它可以
我有一个带有自定义 UITableViewCell 的 UITableViewController。每个单元格有 2 个标签。当单元格被选中时,它会扩展到一个固定值,我通过 tableView(_ t
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if le
我正在尝试根据下载图像的大小实现动态大小的行高。我遇到的问题是当函数 heightForRowAt 运行时图像没有被下载。实现此代码的正确方法是什么。 images是UIImage的数组,rowHei
我正在研究 UI 以使其与设计相同,我使用 heightForRowAt 将第一部分的单元格高度设置为 96px,我尝试了: override func tableView(_ tableView:
我正在使用 UITableViewController 并将 UICollectionView 放在 TableView 单元格的第二行中。问题是我如何动态获取 heightForRowAt 。 我尝
我有一个 View Controller ,它使用名为 searchCell 的自定义单元格来引入内容,我想知道如何获取标签 lblLeft 的高度并在 tableView(_ tableView:
什么时候设置改变 heightForRowAt UITableView 动画是 broken cell 是一个跳跃。如果选择最后一行并滚动到顶部,然后点击折叠行,表格会向上跳。动画坏了。 overri
通常当我想设置行高时再设置 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFl
为什么函数 heightForRowAt 总是找到包含行高的数组,该数组最初设置为 nil,即使在重新加载行后仍然为零。 override func tableView(_ tableView
我有一个整数数组,我试图将数组中所有行的 UITableViewCell 高度设置为 50,并将其余行设置为 0。使用 Swift 3,我的数组返回 [0,1,3,6] 并且我使用 for 循环遍历数
我在一个 ViewController 中有 2 个 tableview。两个表格 View 的单元格高度不同。 在第一个表格 View 中,我通过 heightForRowAt 委托(delegat
我尝试为动态内容设置单元格高度。在单元格中,我使用了两个 UILabel,但我无法从 tableView(_ tableView: UITableView, heightForRowAt indexP
我正在更改每个 TableViewCell 的大小: override func tableView(_ tableView: UITableView, heightForRowAt indexPat
我有一个带有 UITableView 的 View Controller 。使用 RxSwift 填充表数据: let observable = Observable.just(data) obser
每当我重新加载 tableView 时,heightForRowAt 都会在 cellForRowAt 之后调用。它遵循的顺序是: numberofsections -> numberOfRowsI
我对编码还很陌生,所以尝试理解这些概念。 这里我试图获取具有动态单元格高度的 UITableView 的高度。 这是我的代码部分。 override func viewWillAppear(_ ani
我的tableView设置 appTableView.estimatedRowHeight = 200 appTableView.rowHeight = UITableViewAutomaticDim
我是一名优秀的程序员,十分优秀!