我已经构建了一些正确实现iAd的应用程序。这些应用程序在应用程序商店中存在,并且正在显示广告。我现在无法获得任何应用程序(包括曾经正常工作的应用程序)在设备或模拟器上显示iAd。我想知道xcode中是否存在故障或者奇怪的事情发生了什么。也许我只是忽略了一些明显的东西。我做了以下事情:
1)将Binary链接到iAd.framework
2) #import <iAd/iAd.h>
3) #import <iAd/AdBannerView.h>
4) @interface RSBViewController :UIViewController <AdBannerViewDelegate>
5)我的视图控制器在故事板上添加了一个AdBannerView对象
6)将我的AdBannerView连接到
@propery (nonatomic, retain) IBOutlet ADBannerView *aBanner;
7)在viewDidLoad方法中,我确实设置了这样的委托:
_aBanner.delegate = self
8)我已经实现了 - (void)bannerViewDidLoadAd:(AdBannerView *)这样的横幅:
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
NSLog(@"Loading iAd");
if (!self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOn" context:NULL]; banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations]; self.bannerIsVisible = YES; }
}
9)我已实现 - (void)bannerView:(AdBannerView *)banner didFailToReceiveAdWithError:(NSError *)错误如下:
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"Failed Loading iAd");
if (self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:NULL]; banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[UIView commitAnimations]; self.bannerIsVisible = NO; }
}
当我在模拟器或我的设备上运行时输出为:
2013-08-29 21:29:27.643 iAdPracticeApp[1098:c07] Failed Loading iAd
2013-08-29 21:29:57.773 iAdPracticeApp[1098:c07] Failed Loading iAd
2013-08-29 21:30:58.152 iAdPracticeApp[1098:c07] Failed Loading iAd
2013-08-29 21:32:58.542 iAdPracticeApp[1098:c07] Failed Loading iAd
2013-08-29 21:36:58.919 iAdPracticeApp[1098:c07] Failed Loading iAd
2013-08-29 21:40:59.473 iAdPracticeApp[1098:c07] Failed Loading iAd
2013-08-29 21:45:00.997 iAdPracticeApp[1098:c07] Failed Loading iAd
我了解Apple模拟加载的广告并且无法加载广告。我也意识到我可以进入我的iOS设备的开发人员设置,并将错误率更改为0%,50%,80%,100%。无论我尝试什么,我都无法正确加载iAd。我做错了什么?