I am implementing a tableview with 2 xib files.
But in some devices, it's crashing in height for rowAt: function (as per crash logs)
Below is my code
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 0 {
return 340.0
} else {
return (contentHeights[indexPath.row] + 70)
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: “customId1”, for: indexPath) as? customCell1
if let details = Details{
print(detail)
}
cell?.selectionStyle = .none
if cell == nil {
print(“nil cell”)
}
return cell!
} else {
let cell = tableView.dequeueReusableCell(withIdentifier:customId2, for: indexPath) as? customCell2
cell?.selectionStyle = .none
if cell == nil {
print(“nil cell”)
}
return cell!
}
}
I am populating wkweview content in this cellforRow and then reloading the specific row on setting the tableview content.
Although it's working fine on all the devices but crashing on 2 devices out of 350 devices.
Any idea why is it happening?
By doing this you can skip error but check why cell is coming to null. And also check in heightforRowAt contentHeights having that index or not