所以我一直在尝试将iAd集成到我的应用中。我设法让横幅工作得很好,但我在全屏广告上遇到了很多麻烦。我一直关注this tutorial,因为它似乎是我发现的最好和最有益的信息,苹果文档并没有真正得到很多支持。
对于那些想要了解的人,我正在努力实现一种效果,即当用户通过全屏广告获得游戏时。请记住 应用程序也是水平的 ,我还想要一种退出广告的方法,因为我认为iAds没有提供退出按钮,或类似的东西。
问题是广告没有显示,我没有收到任何错误,它似乎没有显示在屏幕上
如果解释很简短或缺乏信息,请道歉,如果您需要我的任何其他信息,请随时询问:)
-Ryan
编辑: 对于那些无法访问超链接或只是想看到我使用的代码的人,这里是:
@implementation GameViewController {
UIView *_adView;
ADInterstitialAd* _interstitial;
BOOL _requestingAd;
}
-(void)showFullScreenAd {
if (_requestingAd == NO) {
_interstitial = [[ADInterstitialAd alloc] init];
_interstitial.delegate = self;
NSLog(@"Ad Request");
_requestingAd = YES;
}
}
-(void)interstitialAd:(ADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error {
_requestingAd = NO;
NSLog(@"Ad didFailWithERROR");
NSLog(@"%@", error);
}
-(void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
NSLog(@"Ad DidLOAD");
if (interstitialAd.loaded) {
CGRect interstitialFrame = self.view.bounds;
interstitialFrame.origin = CGPointMake(0, 0);
_adView = [[UIView alloc] initWithFrame:interstitialFrame];
[self.view addSubview:_adView];
[_interstitial presentInView:_adView];
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self action:@selector(closeAd:) forControlEvents:UIControlEventTouchDown];
button.backgroundColor = [UIColor clearColor];
[button setBackgroundImage:[UIImage imageNamed:@"close-button.png"] forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, 30, 30);
[_adView addSubview:button];
[UIView beginAnimations:@"animateAdBannerOn" context:nil];
[UIView setAnimationDuration:1];
[_adView setAlpha:1];
[UIView commitAnimations];
}
}
-(void)closeAd:(id)sender {
[UIView beginAnimations:@"animateAdBannerOff" context:nil];
[UIView setAnimationDuration:1];
[_adView setAlpha:0];
[UIView commitAnimations];
_adView=nil;
_requestingAd = NO;
}
-(void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd {
_requestingAd = NO;
NSLog(@"Ad DidUNLOAD");
}
-(void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd {
_requestingAd = NO;
NSLog(@"Ad DidFINISH");
}
答案 0 :(得分:2)
嗯,该教程只是my answer here的副本,并且非常过时。
我有newer implementation here。但它仍然不完美。
答案 1 :(得分:1)