在本机调试可以看到广告条,发布到商店上之后,就看不到了……
代码如下:
#pragma mark 广告的实现
- (instancetype)init
{
self = [super init];
if (self) {
...
Class classAdBannerView = NSClassFromString(@"ADBannerView");
if (classAdBannerView != nil)
{
if ([ADBannerView instancesRespondToSelector:@selector(initWithAdType:)]) {
_adView = [[ADBannerView alloc] initWithAdType:ADAdTypeBanner];
} else {
_adView = [[ADBannerView alloc] init];
}
//_adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
//_adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[_adView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[[[CCDirector sharedDirector]view]addSubview:_adView];
[_adView setBackgroundColor:[UIColor clearColor]];
[[[CCDirector sharedDirector]view]addSubview:_adView];
_adView.delegate = self;
[self layoutAnimated:YES];
}
}
return self;
}
- (void)layoutAnimated:(BOOL)animated
{
// As of iOS 6.0, the banner will automatically resize itself based on its width.
// To support iOS 5.0 however, we continue to set the currentContentSizeIdentifier appropriately.
CGRect contentFrame = [CCDirector sharedDirector].view.bounds;
if (contentFrame.size.width < contentFrame.size.height) {
_adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
} else {
_adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
}
CGRect bannerFrame = _adView.frame;
if (_adView.bannerLoaded) {
contentFrame.size.height -= _adView.frame.size.height;
bannerFrame.origin.y = 0;
} else {
bannerFrame.origin.y = 0;
}
[UIView animateWithDuration:animated ? 0.25 : 0.0 animations:^{
_adView.frame = bannerFrame;
}];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
[self layoutAnimated:YES];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[self layoutAnimated:YES];
}
1、苹果iAd投放地区就那么几个,中国区不在iAd投放范围内。
2、申请苹果iAd广告有内部审核流程,一般在app通过审核后再4-7天才会有广告填充