Search code examples
objective-ccocoa-touchios6iad

How to correctly implement iAds? iOS6 deprecation issues


I'm currently trying to add iAd to my app, I've come across a couple of tutorials and have the following in viewDidLoad:

adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, 460.0f);
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[self.view addSubview:adView];
adView.delegate = self;
self.bannerIsVisible = NO;

Problem is I get warnings for requiredContentSizeIdentifiers, ADBannerContentSizeIdentifierPortrait and currentContentSizeIdentifier because they're now deprecated and my ads do not load.

I've had a mooch at the Apple docs and they seem to be mentioning the same things so I'm confused.

How is it supposed to be correctly implemented?


Solution

  • In your createAdBannerView method just comment the lines using requiredContentSizeIdentifiers, ADBannerContentSizeIdentifierPortrait and currentContentSizeIdentifier etc.. And hard code the adBanner frame as below(for iPhone Portrait):

    [_adBannerView setFrame:CGRectOffset([_adBannerView frame], 320,
                                             -[self getBannerHeight])];
    

    Check your ad load or not.. Its worked for me...(But my app is only supporting the portrait view, and its worked)