ios - 如何在使用 UITableViewDiffableDataSource 时设置表格视图单元格的高度(如 heightForRowAt)
问题描述
我想在使用 DiffableDataSource 时检查如何设置 tableview 单元格的高度。这是代码:
func configureDataSource() {
dataSource = MenuItemDataSource(tableView: MenuItemTablevVew, cellProvider: { (tableView, indexPath, menuItem) -> UITableViewCell? in
guard let cell = tableView.dequeueReusableCell(withIdentifier: self.cellIdentifier) as? MenuItemTableCell else { fatalError("Cell not exists")
}
cell.data = menuItem
return cell
})
}
func createSnapshot(menuItems: [MenuItemModel]) {
var snapshot = MenuItemSnapshot()
snapshot.appendSections([.First])
snapshot.appendItems(menuItems)
dataSource.apply(snapshot, animatingDifferences: false)
}
解决方案
推荐阅读
- batch-file - .BAT 文件在 Windows 更新后不断打开无限实例
- javascript - Discord 用户历史记录 - 在 JSON 文件中保存多个内容
- java - 为什么石英 scheduleJob() 执行多次?
- javascript - 使用正则表达式按属性名称和值查找 DOM 元素
- javascript - 保持jquery函数动作的计数
- laravel - 未定义的变量(在视图中找不到变量)
- amazon-s3 - 使用 AWS Rekognition 错误比较两个图像
- android - 是否可以在本地通知中重现“标签”属性的行为?
- c# - 在网站中查找号码并显示
- bitlocker - 如何解锁我的位储物柜加密驱动器。