Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

LastLine

macrumors 65816
Original poster
Aug 24, 2005
1,313
21
Anyone able to offer a little help on this? I just received feedback from Apple advising my app could not be accepted because it contained adbanners that were still visible when no ads were being served, trouble is I can't figure out quite what to do to prevent this problem.

We've completed the review of your application; however, we cannot post this version to the App Store because it displays an empty iAd banner when ad content is not available. The banner within the app should be hidden whenever ad content is not being served by iAd. We have included additional details below to help explain the issue. We hope that you'll consider revising and resubmitting your application.

To handle the case where ad content is not available, you will need to implement a banner view delegate. An example code snippet is included here for your convenience. Additionally, you may wish to review the section "Working with Banner Views" of the iAd Programming Guide for specific details:
<https://developer.apple.com/iphone/prerelease/library/documentation/UserExperience/Conceptual/iAd_Guide/WorkingwithBannerViews/WorkingwithBannerViews.html>

Banner View Delegate to Remove a Banner View When Advertisements are Not Available:
Code:
s
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
 if (self.bannerIsVisible)
  {
      [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// assumes the banner view is at the top of the screen.
      banner.frame = CGRectOffset(banner.frame, 0, -50);
      [UIView commitAnimations];
      self.bannerIsVisible = NO;
  }
}

Now what I'm struggling withs is what to do with that code, when I've tried putting it in it just throws out several red errors so I come seeking advice, anyone able to help me out here?
 
Depends on how you've implemented it.

If you've just simply chucked it into Interface Builder and thought yeh, this should be cool, then you need to make sure you link that ADBannerView up to an outlet in your controller's code, and set the delegate of the banner view to that controller (which will conform to the ADBannerViewDelegate protocol) and then implement the protocol of ADBannerViewDelegate.

A simple way to get rid of the ad is to just animate it off the screen using core animation. Set the frame of the banner view to be outside the screen when it fails to receive an ad. Then animate it back on, setting the frame back to being on the screen when it does.

I'm not sure how you've initialised the bannerview but yeh, it would help if you could provide some of that information on how you've implemented it.
 
Depends on how you've implemented it.

If you've just simply chucked it into Interface Builder and thought yeh, this should be cool, then you need to make sure you link that ADBannerView up to an outlet in your controller's code, and set the delegate of the banner view to that controller (which will conform to the ADBannerViewDelegate protocol) and then implement the protocol of ADBannerViewDelegate.
It's essentially this. I've got the iAd item from the Library into my view using interface builder and added the iAd framework in as, to be honest, that seemed to work (and I suspect from what I can tell does work...just doesn't meet the 'recommendation' that iAd be out of sight when there's no Ads available.
 
There is a video on this from WWDC 2010. If you download the video the second engineer demo is about this very issue.

John
 
Oh really? I'll check it out, any chance you know which video it is off hand, save me trawling through them all (as I haven't downloaded the whole lot yet)

Never mind - just found "Integrating Ads with iAd" I'm assuming this is the one and downloading.
 
Getting an error. Added framework, used apple code but all I get are two big red errors.

Code:
Request for member 'bannerIsVisible' is something not a structure or union

Any ideas how to resolve this?
 
The dot notation has two possible meanings in current Objective-C. There's the old C meaning, which is to reference a member of a struct. That doesn't work on pointers, so if you attempt to do it you'll get an error. In fact, that's what the compiler thinks you are doing and that's why you're getting that error.

The newer alternative meaning added by Objective-C 2.0 is that the following two are equivalent:

someObject.property1;
[someObject property1];

And, similarly, these two achieve the same thing:

someObject.property1 = value;
[someObject setProperty1:value];

The compiler will spot that you intended to use the . as a property accessor only if the object has that property defined.

So, in short, to your ADBannerViewDelegate you need to add a property named 'bannerIsVisible' and the relevant getter and setter. For example, in your header:

Code:
@interface PFWhateverClass : parentClass <ADBannerDelegate>
{
	... other instance variables declared here ...

	BOOL bannerIsVisible
}

@property (nonatomic) BOOL bannerIsVisible;

Then somewhere in your implementation file:

Code:
@synthesize bannerIsVisible;

It's just standard class stuff, nothing iAd specific.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.