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];
}