views:

350

answers:

1

Alright so I have a situation here that is making me go crazy. I am loading a UITableView with a custom UITableViewCell. Now this cell has couple of UILabel's in it.

so the order is:

Label1 Label2 Label3 Label4

Now Label2 has a fixed height. Label1, Label3 and Label4 will need to change their height according to the size of string. I am using the recommended way to calculate the height for each label using: - sizeWithFont:c constrainedToSize: lineBreakMode:UILineBreakModeWordWrap

But the label's are overlapping each other. Not sure how to position these labels?

Or is there a better way to do this?

Thanks

+1  A: 

Position the first label, get its size, and then position each subsequent label by the previous label's frame.

For convenience, you might put this code into a separate method, calling it once to generate that cell's height for use in the -tableView:heightForRowAtIndexPath: delegate method, as well as have those labels set up for the -tableView:cellForRowAtIndexPath: delegate method.

Alex Reynolds