我已經經歷了許多教程,並相信已經做了所有事情,但仍然無法弄清楚,bannerview隨時不顯示廣告,我甚至已將日誌消息放在bannerViewDidLoadAd,didFailToReceiveAdWithError中,但那些不會也顯示。下面是代碼BannerView沒有顯示iAd
我已經註冊了我的帳戶iTunesConnect下獲利,但稅務信息pending.Also我的應用程序只能在potrait模式下運行,所以沒有需要處理的風景線。
在.h文件中:
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface MBViewController : UIViewController <ADBannerViewDelegate>
@property (strong, nonatomic) ADBannerView *bannerView;
@end
在.m文件:
- (void)viewDidLoad
{
[super viewDidLoad];
_bannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
_bannerView.delegate = self;
_bannerView.hidden = YES;
[self.view addSubview:_bannerView];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
NSLog(@"bannerViewDidLoadAd");
CGRect bannerFrame = CGRectMake(0.0, (self.view.frame.size.height - 50), 0.0, 0.0);
[self.bannerView setFrame:bannerFrame];
self.bannerView.hidden = NO;
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"Error receive ad: %@", error);
self.bannerView.hidden = YES;
}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner
willLeaveApplication:(BOOL)willLeave
{
return YES;
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
}
測試iOS和模擬器。當試圖在設備上運行,我大多得到錯誤錯誤接收廣告:錯誤域= ADErrorDomain代碼= 0「操作無法完成未知錯誤」的UserInfo = {0x1e58c950 = ADInternalErrorCode 0,ADInternalErrorDomain = ADErrorDomain,NSLocalizedFailureReason =未知錯誤}或錯誤收到廣告:「操作無法完成的廣告資源不可用」錯誤域= ADErrorDomain代碼= 3的UserInfo = {0x1ed7ec90 = ADInternalErrorCode 3,ADInternalErrorDomain = ADErrorDomain,NSLocalizedFailureReason =廣告資源不可用} – 09apps