views:

92

answers:

1

My window adds a subview (my root ViewController's view).

Such subview is superview of several other subviews.

I have just finished an app, and now I want to add an ad.

Here's some code:

[window addSubview:viewController.view];
viewController.view.frame=CGRectMake(0,0,320,480-48);
viewController.clipToBounds=YES;
Ad *ad=[Ad alloc] initWithFrame:CGRectMake(0,480-48,320,48)];

The above viewController has several subviews, but they won't resize. The above viewController.view was 320,480 originally and was completely filled with subviews, until the last pixel on the bottom. And after I change its height from 480 to 460, the subviews do not resize, so on the bottom of the view (where the ad goes) some subviews aren't visible.

How can I get the subviews to resize so to fit the parent view (viewController.view), when the latter has its height reduced by 20px? (I am aware that they'll be deformed a bit)

+1  A: 

You need to set the autoresizing mask for the subviews:

ad.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

See the UIView documentation for more details.

Rob Napier
@Rod Napier I'm not sure you understood... but the ad is not a subview of the viewController.view. It's a sibling actually. Do you still maintain the above?
GSchv
@Rod Napier yeah I think the above holds. Thanks.
GSchv