Question

i have an adbanner on my first screen (ViewController) and i was wondering what would be the best possible way to implement adbanners on my other screens (ViewControllers) so that my app doesnt get rejected by apple just because i did it wrong - i have like 20 of them.

Do i just simply copy and paste the banner from the first screen onto the rest or do i have to rewrite and add some code

This is my AdBanner code in the .h file

@interface ViewController : UIViewController <ADBannerViewDelegate>
@property (weak, nonatomic) IBOutlet ADBannerView *banner;

@end

This is my AdBanner code in the .m file

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
self.banner.delegate = self;
}

- (void) viewDidLayoutSubviews {
if (self.banner.bannerLoaded) {
    CGRect contentFrame = self.view.bounds;
    CGRect bannerFrame = self.banner.frame;
    contentFrame.size.height -= self.banner.frame.size.height;
    bannerFrame.origin.y = contentFrame.size.height;
    self.banner.frame = bannerFrame;
}
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
NSLog(@"bannerViewActionShouldBegin");
return YES;
}

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

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"didFailToReceiveAdWithError");
}

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

@end

any suggestions and help is much appreciated.

Was it helpful?

Solution

Grab the iAdSuite sample code from Apple and look at the ContainerBanner sample. This lets you have one place where you have your iAd code and the BannerViewContainer handles all the heavy lifting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top