在swift5中,tableview中有多個cell想設(shè)置不同的高度,用到heightForRowAt: 方法的時候,出現(xiàn)以下圖片中的報錯:

解決方法:在?tableView(_:cellForRowAt:) 方法中,將let cell =?dequeueReusableCell(withIdentifier:for:) as!UITableViewCell() 分別寫進switch的不同case中。

在swift5中,tableview中有多個cell想設(shè)置不同的高度,用到heightForRowAt: 方法的時候,出現(xiàn)以下圖片中的報錯:
解決方法:在?tableView(_:cellForRowAt:) 方法中,將let cell =?dequeueReusableCell(withIdentifier:for:) as!UITableViewCell() 分別寫進switch的不同case中。