I'm trying to get this to work with code in a ViewController's view:
but I can't get it to work.
I've tried
-(void)loadView {
UIView *contentView = [[[UIView alloc] init] autorelease];
self.view = contentView;
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(5,5,0,100);
button.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[contentView addSubview:button];
}
but the width of the button is still the width of the superview...
I'm sure there's an easy explanation.
Thanks, everybody!
Antonio
-initWithFrame:
is the designated initializer for UIView. On the Mac side (NSView) I know strange things can happen when using -init
instead of -initWithFrame:
. Perhaps this is the problem?