我有一个标签栏应用程序,它具有表视图作为子视图。我需要在标签栏上方的底部显示广告横幅。有时会看到广告横幅,有时会很长时间看不到。有时它会在不可用时离开白色视图,有时则不可用。我没有得到这里发生的事情:
我在用:
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame=CGRectZero;
frame.size = [ADBannerView sizeFromBannerContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
// Place frame at the bottom edge of the screen out of sight
frame.origin = CGPointMake(0.0, 317);
// Now to create and configure the banner view
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:frame];
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
// Set the delegate to self, so that we are notified of ad responses
adView.delegate = self;
adView.hidden = YES;
[self.view addSubview: adView];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
NSLog(@"ad now available");
banner.hidden = NO;
// Get a brand new frame
CGRect newFrame=CGRectZero;
CGPoint frameOrigin=CGPointZero;
// Set the origin
frameOrigin=CGPointMake(0.0, CGRectGetMaxY(self.view.bounds));
newFrame.origin=frameOrigin;
// Set the size
newFrame.size=[ADBannerView sizeFromBannerContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
CGFloat bannerHeight = newFrame.size.height;
CGFloat bannerOffset=0.0;
// Determine where the new frame should be
if (!self.isBannerVisible)
{
// It should be visible, raise it up
bannerOffset=-bannerHeight;
}
CGRect offSetRect=CGRectOffset(newFrame,0.0f,bannerOffset);
[UIView animateWithDuration:0.2
animations:^{banner.frame= offSetRect;}
completion:^(BOOL finished){
if (bannerOffset<0){
self.isBannerVisible=YES;
}else{
self.isBannerVisible=NO;
}
}
];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"error is===>%@",error);
}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
return YES;
}
有时错误是:
Error Domain=ADErrorDomain Code=0 "The operation couldn’t be completed. Unknown error" UserInfo=0x8c53410 {ADInternalErrorCode=0, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Unknown error}
有时是:
Error Domain=ADErrorDomain Code=3 "The operation couldn’t be completed. Ad inventory unavailable" UserInfo=0x7e64780 {ADInternalErrorCode=3, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Ad inventory unavailable}
请有人帮忙!!