這是我第一次整合iAds的體驗。我用下面的鏈接如何以編程方式在iOS中的iAds Banner上展示廣告
http://codewithchris.com/iad-tutorial/
我實現它完美。我的應用程序顯示AddBannerView完美,但廣告隱藏並顯示不起作用。我通過使用storyboard添加了adBannerView,並連接了它的代表和IBOutlets。
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (! bannerIsVisible) {
// If banner isn't part of view hierarchy, add it
if (advertiseView.superview == nil) {
[self.view addSubview:advertiseView];
}
[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];
bannerIsVisible = YES;
}
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
NSLog(@"Failed to retrieve ad");
if (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];
bannerIsVisible = NO;
}
}
顯示您使用的代碼 –
該教程相當過時。檢查[這裏 - 斯威夫特](http://stackoverflow.com/a/28639200/2108547)或[here-ObjC](http://stackoverflow.com/a/28708377/2108547)爲更好的實現。 –
究竟是「不工作」?你包含的截圖顯示它實際上工作。請更具體一些。 – jcaron