2
我已將iAd添加到我的iPhone應用程序中,處於應用程序的頂部。最初我把它放在x = 0和y = -50的位置,以便它來自屏幕外。我用它下面的代碼在我的.m:xcode 4.3 - 故事板 - iAd不停地移動
- (void)bannerView:(ADBannerView *)abanner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// Assumes the banner view is placed at the bottom of the screen.
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
- (void)bannerViewDidLoadAd:(ADBannerView *)abanner
{
if (!self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// Assumes the banner view is just off the bottom of the screen.
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
當我的應用程序推出的iAd獲得顯示在頂部沒有任何問題。但是當我打開另一個應用程序並回到它(沒有殺死它,所以我的應用程序在後臺運行)橫幅移動另一個50像素向下
任何想法?
硬編碼它留下了白色的空白欄時,沒有廣告。這就是爲什麼我最初將它從屏幕上移開,然後在有廣告顯示時將其移開。 – Adeeb 2012-03-22 13:12:05
我的意思是hardcode它已關閉,它的位置 - 不要把它放在固定的地方。你嘗試了建議的代碼嗎? – 2012-03-22 13:15:25
優秀!!謝謝 – Adeeb 2012-03-22 14:06:55