2

ビュー内にはテーブルと広告バナーがあり、これらはすべて 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];  
}
4

1 に答える 1

0

バナーを非表示にするためにどのような方法を使用していますか。removeFromSuperviewを使用していない場合:親ビューのサイズを変更すると、ビューのサイズが自動サイズ変更されます(これにより、ビューが画面に合わせて自動的に調整される場合があります)。

うまくいくものが見つかるまで、Interface Builder(インスペクターの[サイズ]タブ)内のビューの自動サイズ変更オプションをいじることをお勧めします。

于 2010-09-20T01:24:57.997 に答える