Reputation: 341
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
Upvotes: 2
Views: 792
Reputation: 7283
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...
Upvotes: 4