Reputation: 3233
I have an app that starts in Landscape mode and I have the following UIView that is created to go full screen.
- (void)loadSignupScreen {
CGFloat screenHeight = self.view.frame.size.height;
CGFloat screenWidth = self.view.frame.size.width;
self.signupContainer = [[UIView alloc] initWithFrame:self.view.bounds];
[self.signupContainer setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin];
UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
[bgImageView setBackgroundColor:[UIColor darkGrayColor]];
[bgImageView setAlpha:0.8];
[self.signupContainer addSubview:bgImageView];
[self.view addSubview:self.signupContainer];
}
The problem is that when I rotate the screen to portrait it isn't full screen instead it only seems to be about 3/4 the length of the screen. How can I make it fill the screen on rotate? I don't have a problem using the autosizing in IB just when it is programmed.
Thanks
Upvotes: 0
Views: 221
Reputation: 7381
You are assigning the wrong autoresizingMask
to the signupContainer
. It should just be flexible height and width.
[self.signupContainer setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
Also the UIImageView
needs an autoresizingMask
.
UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
[bgImageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
Upvotes: 2