1

My storyboard elements are subviews of containerView and containerView is a subview of the main view. I am trying to resize the height of my container view when an ad is available to show but I cannot get that to work. I am able to offset the view up, but I am not able to resize it. I have seen quite a bit a posts about this, but all suggestions I've read basically say to confirm Autolayout is not checked. I have confirmed that Autolayout is not checked in each element of my storyboard but still am not having success with this. The ad banner (placed just off screen at [0, 480] pops up nicely from the bottom just like I want it to, but it covers up my storyboard elements which is just plain UNACCEPTABLE. I will not stand for this! I need some help guys and gals…Please see code below:

-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    if (_bannerIsVisible == NO)
    {
        NSLog(@"Ad Loaded");

        [UIView beginAnimations:@"animateAdbannerOn" context:nil];

        //_containerView.frame = CGRectOffset(_containerView.frame, 0, -50);

        _containerView.frame = CGRectMake(_containerView.frame.origin.x,

                                 _containerView.frame.origin.y,

                                 _containerView.frame.size.width,

                                 _containerView.frame.size.height-50);


        banner.frame = CGRectOffset(banner.frame, 0, -50);

        [UIView commitAnimations];

        _bannerIsVisible = YES;
    }
}
user2954945
  • 121
  • 9

2 Answers2

0

Try it like this:

-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (_bannerIsVisible == NO)
{
    NSLog(@"Ad Loaded");

    [UIView beginAnimations:@"animateAdbannerOn" context:nil];

    //_containerView.frame = CGRectOffset(_containerView.frame, 0, -50);

    CGRect frame = CGRectMake(_containerView.frame.origin.x,

                             _containerView.frame.origin.y,

                             _containerView.frame.size.width,

                             _containerView.frame.size.height-50);

    [_containerView setFrame:frame];

    CGRect frame2 = banner.frame;
    frame2.origin.x = 0;
    frame2.origin.y = -50;
    [banner setFrame:frame2];

    [UIView commitAnimations];

    _bannerIsVisible = YES;
}
}
iCode
  • 1,456
  • 1
  • 15
  • 26
  • So it looks like I was almost there. I am currently at work right now. I will try this when I get home. Thank you for the prompt reply! – user2954945 Mar 03 '14 at 13:36
0

You have just changed the frame of your containerView. This does not in any way change the frames of the subviews of containerView. You either have to make containerView a scrollview or change the frames of every component.

Puneet Sharma
  • 9,369
  • 1
  • 27
  • 33
  • Yes, that is what I was thinking myself. The reason I was trying it this way is because I saw a post where someone said that this could be done. Also, last night I think I saw an option in my storyboard settings to "automatically resize subviews" or something of that nature? Not sure what that option does, but I will see what happens later on when I get off work I guess! – user2954945 Mar 03 '14 at 13:40
  • Well I tried your suggestion, and it I get the same result! The container view and its subviews do not resize. Is this true that I somehow have to resize every element within the container view or is their a setting so that when I resize my container view, its subviews will adjust proportionally? – user2954945 Mar 04 '14 at 00:10