How to set height of tableview cell while using UITableViewDiffableDataSource (Like heightForRowAt)

Viewed 839

I was wondering to check how to set the height of tableview cell while using DiffableDataSource. This is code:

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)
}
0 Answers
Related