No index path for table cell being reused

前端 未结 13 1497
执念已碎
执念已碎 2021-02-04 05:18

This started to happen out of the blue. Any ideas: Code:

CUSTOMCLASSNAME (I have replaced the actual class name as it contains the name of the client.)

Initialis

13条回答
  •  北海茫月
    2021-02-04 06:02

    In my case (pretty stupid one), I used the if let syntax inside cellForRowAt like that:

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if let cell = tableView.dequeueReusableCell(withIdentifier: "carCell", for:
        indexPath) as? carTableViewCell {
            // Did some stuff here
            return CarTableViewCell()
        else {
            return CarTableViewCell()    
        }
    }
    

    As you may see, I returned i generic carTableViewCell(), and that's what gave me that despicable error... I hope it will ever help someone haha (:

    Happy Coding!

提交回复
热议问题