2

I'm working on the UI to make it same as design, I used heightForRowAt to make first section's cell's height to 96px, and I tried:

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        switch indexPath.section {
        case 0:
            return 96.0
        default:
            return 56.0
        }
}

but it crashed and I searched everywhere but the problem was never solved

so I tried for testing:

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 56.0
}

but It also crashed.

Xcode just gives me Thread 1:signal SIGABRT Error, and I couldn't find a solution. Why this happening to me?

+++ Console Message When Error Happens

screenshot of console message

Krunal
  • 68,602
  • 40
  • 230
  • 241
Cyan Lee
  • 341
  • 1
  • 11

1 Answers1

4

Your error of thre crash has nothing to do with custom heights that you mentioned. In your method to get the cell for row at index path you are trying to dequeue two cells for same index path...

You must have something like this in your code...

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "ident", for: indexPath)
    let cell2 = tableView.dequeueReusableCell(withIdentifier: "ident", for: indexPath)
}

And iOS is crashing to let you know that you can only dequeue one cell per index path...

Ladislav
  • 6,767
  • 5
  • 24
  • 29