tags:

views:

194

answers:

1

Inside my view, I have a table and an ad banner, all of which are created through Interface Builder. But I noticed that my view.frame.size.height seems to change through the course of execution of my app even though I haven't changed the size.

Can someone explain to me why this is happening?

What I'm doing is moving the ad banner off screen on viewDidLoad, at which point, if I print out self.view.frame.size.height, the value is: 460.00. At this time, I am also increasing the tableView's size so it takes up the space the adBanner once occupied and moving the adBanner off-screen at the same time.

Then later on when I get the bannerViewDidLoadAd message, I once again print out the self.view.frame.size.height, at which point it is 367.00. I don't understand why the view's size has changed.

- (void)moveAdvertOffScreen
{
    // Make the table view take up the void left by the banner (320x50 block)

    CGRect originalTableFrame = self.tableView.frame;
    CGFloat newTableHeight = self.view.frame.size.height;

    CGRect newTableFrame = originalTableFrame;
    newTableFrame.size.height = newTableHeight;

    // Position the banner below the table view (offscreen)
    CGRect newBannerFrame = self.adBannerView.frame;
    newBannerFrame.origin.y = newTableHeight;

    self.tableView.frame = newTableFrame;   
    self.adBannerView.frame = newBannerFrame;    
}

- (void)moveAdvertOnScreen
{
    CGRect newBannerFrame = self.adBannerView.frame;    
    newBannerFrame.origin.y = self.view.frame.size.height - newBannerFrame.size.height;

    CGRect originalTableFrame = self.tableView.frame;
    CGFloat newTableHeight = self.view.frame.size.height - newBannerFrame.size.height;

    CGRect newTableFrame = originalTableFrame;
    newTableFrame.size.height = newTableHeight;

    [UIView beginAnimations:@"BannerViewIntro" context:NULL];
    self.tableView.frame = newTableFrame;
    self.adBannerView.frame = newBannerFrame;
    [UIView commitAnimations];  
}
A: 

What method are you using to hide the banner. If you aren't using removeFromSuperview: then the view is going to get autoresized when you resize the parent view (which may in turn happen automatically to fit the view to the screen, etc).

I'd suggest having a fiddle with the autoresize options for the view within Interface Builder (on the Size tab of the Inspector) until you find something that works.

grahamparks
I'm readjusting the frame size to move the banner off screen and not hiding it per say.
Justin Galzic