iAd - Hiding when no Ads are being served

Discussion in 'iOS Programming' started by LastLine, Jun 26, 2010.

  1. LastLine macrumors 65816

    Aug 24, 2005
    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.

    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?
  2. MokSiFu macrumors member

    Jul 24, 2009
    Down Under
    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.
  3. LastLine thread starter macrumors 65816

    Aug 24, 2005
    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.
  4. JohnMC macrumors 6502

    May 5, 2006
    Duluth, MN
    There is a video on this from WWDC 2010. If you download the video the second engineer demo is about this very issue.

  5. LastLine thread starter macrumors 65816

    Aug 24, 2005
    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.
  6. codenamecueball macrumors regular

    Jul 28, 2009
    Getting an error. Added framework, used apple code but all I get are two big red errors.

    Request for member 'bannerIsVisible' is something not a structure or union
    Any ideas how to resolve this?
  7. chainprayer macrumors 6502a

    Feb 10, 2008
    Got the same issue and am looking for a fix. Did you happen to find anything?
  8. Thomas Harte macrumors 6502

    Nov 30, 2005
    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];

    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:

    @interface PFWhateverClass : parentClass <ADBannerDelegate>
    	... other instance variables declared here ...
    	BOOL bannerIsVisible
    @property (nonatomic) BOOL bannerIsVisible;
    Then somewhere in your implementation file:

    @synthesize bannerIsVisible;
    It's just standard class stuff, nothing iAd specific.

Share This Page