swift - Swift 不要在自定义单元格中工作自动高度
问题描述
只是单元格的自定义类
class CarCell: UITableViewCell {
override func layoutSubviews() {
MainImageView.leftAnchor.constraint(equalTo: self.leftAnchor, constant: spacing * 5).isActive = true
MainImageView.topAnchor.constraint(equalTo: self.topAnchor, constant: spacing).isActive = true
MainImageView.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -spacing * 5 ).isActive = true
MainImageView.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -spacing).isActive = true
MainImageView.heightAnchor.constraint(equalTo: MainImageView.widthAnchor).isActive = true
}
不要工作 2 底线。
class TableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(CarCell.self, forCellReuseIdentifier: "CarCell")
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 44
}
我可以创建这个非程序化的,我需要这个结果
解决方案
推荐阅读
- reactjs - 使用 react-router 和 expressJS 的客户端路由只能工作一层
- javascript - WordPress 网站上的奇怪 JS 警报
- c# - 从 ConcurrentDictionary 中删除项目
- c++ - 在模板类中使用 auto 的类使用不完整
- sublimetext3 - 如何在多个 SublimeText 项目中共享 ESlint 设置
- cocoa - 如何在 NSPopUpButton 中创建命名部分
- angularjs - 使用 Spring Boot 上传多个文件
- reactjs - Webpack 不提供 React 组件
- firebase - Firebase - 云函数 - “错误:需要使用事件参数调用云函数。”
- html - 在客户端丰富/基于 AJAX 的应用程序中设计登录模块