View Full Version : UILabel/UITextView Autosizing

Jul 24, 2010, 01:50 PM
I have a UIView that creates a couple of the above with the following (UILabel example)

dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(149.0, 69.0, 155.0, 21.0) ];

I have just set shouldAutorotateToInterfaceOrientation to return YES in my app, and you've probably guessed what I'm about to say/ask.

Of course my view won't look right in landscape. I know how to do it in IB by using the Autosizing section, but is it possible in code and if so how?


Jul 25, 2010, 04:32 AM
Set the autoresizingMask (http://developer.apple.com/iphone/library/documentation/uikit/reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/autoresizingMask) property.