views:

446

answers:

2

I'm working on a iPhone product page where some of the fields can be fairly long (product name etc.) I've created the page layout in IB, and use UILabels to show the text fields. For those long text labels I'd like the height of the label to scale and push the other labels further down. Is this possible using IB, or would I have to do everything in code? (Compute height and position of all the UILabels.)

I'm presently able to get the text in the labels to wrap and fill the available space, but I have to reserve space for this. When the label is only one line it leaves lots of unused space before the next label.

A: 

It did some searching for this same thing and as far as I can tell you have to manually resize and position the labels.

If you want to know how to dynamically resize a label, this is how I am doing it:

myLabel.frame = CGRectMake(227.0, 12.0, 22.0, 21.0);

I am happy to be wrong on this one, since I don't like having to do this either.

Tony Eichelberger
+2  A: 

You will have to calculate the heights dynamically in code. I'm not sure what you're doing exactly, but you may want to start using a UITableView and return variable height cells. I wrote a blog post on how to do this at Cocoa Is My Girlfriend.

Matt Long