ビュー内にはテーブルと広告バナーがあり、これらはすべて Interface Builder で作成されています。しかし、サイズを変更していなくても、アプリの実行中に view.frame.size.height が変化しているように見えることに気付きました。
なぜこれが起こっているのか誰かが私に説明できますか?
私がやっていることは、viewDidLoad で広告バナーを画面外に移動することです。その時点で、self.view.frame.size.height を出力すると、値は 460.00 になります。現時点では、tableView のサイズも大きくしているため、adBanner がかつて占有していたスペースを占有し、同時に adBanner を画面外に移動しています。
その後、bannerViewDidLoadAd メッセージを受け取ると、もう一度 self.view.frame.size.height を出力します。この時点で 367.00 です。ビューのサイズが変更された理由がわかりません。
- (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];
}