I have a UITableView and I'm having trouble with the formatting of the cells.

This is what it looks like this: "Image Link"

As you can see, the cells with a percent grade have the textLabel (the class name) higher than the cells without the percent grade. The problem is in the cellForRowAtIndexPath method in the UITableViewDelegate. I set the text of the textLabel (the part of the table view with the class name) and then if the detailTextLabel has a percent, I set the cell.detailTextLabel.numberOfLines = 2;. I don't see why this affects the textLabel though. I thought the two labels in the content view were independent of each other.

How would I fix this problem and get my labels to format correctly?

有帮助吗?

解决方案

You can solve this problem by adding two separate new labels in your cell. Don't use the default labels. You can refer to this link for code snippet and for more detailed explanation.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top