views:

157

answers:

1

Hi... I've 3 UILabel's inside a custom UITableViewCell. The width of these UIlabels must change when the device changes it's orietation because the tableView's width changes. My problem was how could I resize the label when the device rotation happens.

+3  A: 

The easiest way is to set the labels' autoresizingMask to appropriate values. You'll probably want something like this:

leftLabel.autoresizingMask   = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;
centerLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
rightLabel.autoresizingMask  = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin;
Ole Begemann