我正在使用以下代碼來設置共享的iAd橫幅。共享iAd橫幅bannerViewDidLoadAd未被調用
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
_adView = [[ADBannerView alloc]init];
}
ViewController.m
-(void) viewWillAppear:(BOOL)animated {
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication ]delegate];
_adView = [appdelegate adView];
_adView.delegate = self;
self.canDisplayBannerAds = true;
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}
bannerView:didFailToReceiveAdWithError
如預期,但bannerViewDidLoadAd
不會被調用獲取調用。我試圖在iAd旗幟加載時在屏幕上移動一些按鈕。
感謝丹尼爾。如果我使用self.canDisplayBannerAds = true;並消除其他橫幅廣告,它仍然會調用bannerViewDidLoadAd:? –
@JasonBestor簡單地說,沒有。你可以用更多的代碼來實現這個目標,但是如果你打算這麼做的話,你可以像上面所展示的那樣實現iAd橫幅。 –
@DanialStorm我問,因爲我的應用程序有幾個其他視圖,其中使用self.canDisplayBannerAds = true;會在廣告出現時自動向上移動桌面視圖等等。此外,當我導航回主視圖時,橫幅視圖正在消失。 –