I have a tab bar application which have table views as sub views. I need to show ad banner at bottom just above the tab bar. The ad banner sometimes is seen and sometimes not for a long time. Sometimes it leaves the white view when as not available and sometimes not. I am not getting what is happening here:
I am using:
- (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;
}
Sometimes error is:
Error Domain=ADErrorDomain Code=0 "The operation couldn’t be completed. Unknown error" UserInfo=0x8c53410 {ADInternalErrorCode=0, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Unknown error}
sometimes it is:
Error Domain=ADErrorDomain Code=3 "The operation couldn’t be completed. Ad inventory unavailable" UserInfo=0x7e64780 {ADInternalErrorCode=3, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Ad inventory unavailable}
Please someone help!!