1

I am trying to put an iad banner on my free version app, the banner runs smoothly when pressed and the view confirmation that the test ads are running correctly. But then when i closed that view my application was stocked, i can pressed the buttons but they did not execute their actions. This is the what i do that's why i think that the bannerViewActionDidFinish: was not called. In bannerViewActionShouldBegin: i set the buttonTest setEnabled = NO, then made it buttonTest setEnabled = YES in bannerViewActionDidFinish:. The result was the button became disabled and not enabled when the banner test view was closed.

.h file

#import <iAd/iAd.h>

ADBannerView *adView;
BOOL bannerIsVisible;

@property (nonatomic, assign)BOOL bannerIsVisible;

.m file

@synthesize bannerIsVisible;

- (void)viewDidLoad
{
    adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    adView.frame = CGRectOffset(adView.frame, 0, -50);
    adView.requiredContentSizeIdentifiers = [NSSet       setWithObject:ADBannerContentSizeIdentifierLandscape];
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
    [self.view addSubview:adView];
    adView.delegate=self;
    self.bannerIsVisible=NO;      

    [super viewDidLoad];
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    if (!self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, 50);
        [UIView commitAnimations];
        self.bannerIsVisible = YES;
    }
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    if (self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, -50);
        [UIView commitAnimations];
        self.bannerIsVisible = NO;
    }
}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
    NSLog(@"Banner view is beginning an ad action");

   [buttonTest setEnabled:NO];

   return YES;
}

-(void)bannerViewActionDidFinish:(ADBannerView *)banner
{
   // resume everything you've stopped

   [buttonTest setEnabled:YES];
}

- (void)viewDidUnload
{
    adView.delegate = nil;
}
john.k.doe
  • 7,533
  • 2
  • 37
  • 64
Herin
  • 11
  • 4

1 Answers1

0

in this case, you can check the willLeave: argument of bannerViewActionShouldBegin:willLeaveApplication:

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
     NSLog(@"Banner was clicked on; will%sleave application", willLeave ? " " : " not ");

    [buttonTest setEnabled:!willLeave];

    return YES;
}

this way, buttonTest remains enabled if you don't leave the application for the iAd click-through.

john.k.doe
  • 7,533
  • 2
  • 37
  • 64