how to implement AdBannerview and ADBannerview delegate

18,320

Solution 1

The reason why is you told the AdBannerView that you are its delegate but you never put it in your implementation file. Your implementation file should look like this (notice the line with @implmentation):

//
//  ADBannerViewDelegate.m
//

#import "ADBannerViewDelegate.h"

@implementation ADBannerViewDelegate<ADBannerViewDelegate>

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
    NSLog(@"bannerview did not receive any banner due to %@", error);}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner{NSLog(@"bannerview was selected");}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave{return willLeave;}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {NSLog(@"banner was loaded");}

@end

And also you shouldn't name your class ADBannerViewDelegate. Your class should be a delegate (respond to it) to ADBannerView but not be named after it.

Solution 2

i successfully integrated iAds in my app using this tutorial:
http://www.raywenderlich.com/1371/how-to-integrate-iad-into-your-iphone-app
might help you too.

Solution 3

You don't try to implement a class named ADBannerViewDelegate, you put those methods in the implementation for your view class.

(If you actually named your view class "ADBannerViewDelegate", don't. It's confusing.)

Solution 4

For me it was the target and the device, I ran it on the 4.3 simulator and my ipad 2 but the app was for iphone 5.1, when I changed the target all went swimmingly

Solution 5

you can Use this link its very helpful

http://codewithchris.com/iad-tutorial/

Share:
18,320
jason
Author by

jason

Updated on June 11, 2022

Comments

  • jason
    jason almost 2 years

    I am having trouble implementing ADBannerView and its delegate protocol.

    I implemented the following code in my view class (also made the view conform to the ADBannerViewDelegate protocol):

    //add iAds
    ADBannerView *adView = [[ADBannerView alloc] initWithFrame: CGRectMake(0, 318, 320, 50)];
    adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil];
    adView.delegate = self; 
    //adView.delegate = ADBannerViewDelegate;
    [self.view addSubview: adView];
    

    then I created a class for the ADBannerViewDelegate, with the following .m

    //
    //  ADBannerViewDelegate.m
    //
    
    #import "ADBannerViewDelegate.h"
    
    @implementation ADBannerViewDelegate
    
    - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
        NSLog(@"bannerview did not receive any banner due to %@", error);}
    
    - (void)bannerViewActionDidFinish:(ADBannerView *)banner{NSLog(@"bannerview was selected");}
    
    - (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave{return willLeave;}
    
    - (void)bannerViewDidLoadAd:(ADBannerView *)banner {NSLog(@"banner was loaded");}
    
    @end
    

    the banners are eventually presented but the console keep throwing the following type of errors:

    2011-02-27 15:00:54.108 app[31639:207] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=5 "The operation couldn’t be completed. Banner view is visible but does not have content" UserInfo=0x6356a40 {ADInternalErrorCode=5, NSLocalizedFailureReason=Banner view is visible but does not have content}
    

    and the delegate functions are not doing anything , so no NSLog at all. Obviously not catching the errors.

    I am stumped. I guess I am missing something in the linkage of the Adbanner view calls in the view and the delegate. Not sure how to do it or what is wrong.

    Any help? Thanks in advance.

    Jason