- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 iOS 11,我可以成功获得自定尺寸 UITableViewCellStyle.subtitle
单元格通过设置 numberOfLines
动态调整其高度detailTextLabel
上的属性(property)为 0。
public class SubtitleCell: UITableViewCell {
public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
self.textLabel?.font = UIFont.preferredFont(forTextStyle: .headline)
self.detailTextLabel?.numberOfLines = 0
}
}
tableView.estimatedRowHeight = UITableViewAutomaticDimension
tableView.rowHeight = UITableViewAutomaticDimension
subtitle
单元格样式正确调整大小?当我使用实时 View 检查器时,我在 iOS 11 或 iOS 10 单元格的表格 View 单元格中看不到任何约束。所以,我觉得 Apple 对默认 UITableViewCell 样式进行了基本更改,但我找不到任何对它的引用。
最佳答案
在 iOS 10 中,为了启用自动调整大小功能,您必须继承 UITableViewCell
, 并为 Custom
添加约束样式单元格。注意,它不适用于 Subtitle
样式单元格,因为 Apple 不让您能够将约束添加到字幕标签和标题到表格 View 单元格的框架。
您还必须为 tableView.estimatedRowHeight
提供原始值。在 iOS 10 中。
您可以使用可用性检查为 SubtitleCell
运行不同的单元配置。适用于 iOS 10 和 11。
关于ios - UITableViewCellStyle 字幕自动布局从 iOS 10 到 iOS 11 的变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46413010/
刚刚发生了一件奇怪的事情,我试图构建我的自定义表格单元格,但没有调用我的 initWithStyle。 - (id)initWithStyle:(UITableViewCellStyle)style
我正在使用Xamarin iOS,在iOS 9.2设备上,具有UITableViewCellStyle.Value1单元格样式的UITableView单元格具有与DetailTextLabel重叠的T
我对 UITableViewCellStyle 有点困惑。我想像这样创建一个自定义 UITableViewCell: 但是当我运行应用程序时,文本和图像没有出现在单元格中。在 Storyboard 中
我知道我可以将类或 NIB 文件注册为 UITableViewCell。但我想做 iOS 6 的方式 UITableViewCell *cell = [tableView dequeueReusabl
根据 this Xamarin docs page ,我正在 Xamarin iOS 应用程序中构建 TableView : 自定义 UITableViewSource 类,覆盖 GetCell()、
我想为默认表格单元格使用 UITableViewCellStyle.Subtitle 样式。我在 an SO answer 中找到了答案像这样: func tableView(tableView: U
我有一个tableViewCell let cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier:
使用 iOS 11,我可以成功获得自定尺寸 UITableViewCellStyle.subtitle单元格通过设置 numberOfLines 动态调整其高度detailTextLabel 上的属性
我是一名优秀的程序员,十分优秀!