Joon. P
Joon. P

Reputation: 2298

iAd banner appears even if there is no ADBannerView on storyboard?

Here is my sample project that displays an iAd banner at the bottom of the view.

viewcontrollerOne.h

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>

@interface viewcontrollerOne : UIViewController <ADBannerViewDelegate>
@end

viewcontrollerOne.m

#import "viewcontrollerOne.h"

@implementation viewcontrollerOne

- (void)viewDidLoad {
    [super viewDidLoad];
    self.canDisplayBannerAds = YES;
}
#pragma mark iAd Delegate Methods
-(void) bannerViewDidLoadAd:(ADBannerView *)banner
{

}
-(void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError*)error
{

}

@end

iAd banner appears on the bottom of the screen even when I don't have an ADBannerView. Also, this banner appears on the other segued ViewControllers that have

#import <iAd/iAd.h>

and

<ADBannerViewDelegate> 

and

self.canDisplayBannerAds = YES;

Is this the proper way of implementing iAd banners? If so, why do all the other tutorials implement ADBannerView on storyboard, and use [self.view addSubview: myAdBanner];??

I am so confused...

Upvotes: 1

Views: 177

Answers (1)

Daniel Storm
Daniel Storm

Reputation: 18878

Using self.canDisplayBannerAds = YES; will automatically create an ADBannerView for you and display it on the bottom of your devices screen. If you'd like to implement an ADBannerView programmatically remove self.canDisplayBannerAds = YES; and do so. Here's a nice implementation of iAd and AdMob banner ads.

Upvotes: 1

Related Questions