PDA

View Full Version : Properly hiding iAds




chainprayer
Jul 18, 2010, 07:13 PM
My app was recently rejected after implementing iAd support. The email I received back stated I needed to hide the view when no ad was present. The following was provided:

Banner View Delegate to Remove a Banner View When Advertisements are Not Available:

- (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;
}
}

I tried adding that to my main view controller that contains the ad view and received many compile error messages. What would be the proper way of hiding the ads?

EDIT: Yes I am compiling with the most recent SDK and I have included the iAd framework



dejo
Jul 18, 2010, 09:25 PM
What errors are you getting?

LastLine
Jul 20, 2010, 01:52 AM
OK so stage 1 is simple. Remove all the iAd code and frameworks from your app. Seriously.


Second stage.
Download This Video (https://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/adc.apple.com.4088624952.04088624954.4144525684?i=2117399219) from the WWDC 2010 series, it's all based around iAd.

Watch through and observe the "Ideal Implementation" otherwise known as "the only way you're getting your iAd app on our store Implementation" this describes it faultlessly, worked an absolute charm for me.


Hope that helps, it was ages of hunting before I got it right and that does it so simply.

themoonisdown09
Jul 20, 2010, 03:47 PM
Apple's iAd Programming Guide (http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/iAd_Guide/Introduction/Introduction.html) will show you how to properly display and hide the iAd banner. This is how I got mine working.

tdog09
Jul 20, 2010, 04:19 PM
OK so stage 1 is simple. Remove all the iAd code and frameworks from your app. Seriously.


Second stage.
Download This Video (https://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/adc.apple.com.4088624952.04088624954.4144525684?i=2117399219) from the WWDC 2010 series, it's all based around iAd.

Watch through and observe the "Ideal Implementation" otherwise known as "the only way you're getting your iAd app on our store Implementation" this describes it faultlessly, worked an absolute charm for me.


Hope that helps, it was ages of hunting before I got it right and that does it so simply.


Agreed, it's a great video, watch it!


Also, have any of you received this warning when click on the iAd banner:

The view controller <ADRemoteViewController: 0x176d00> returned NO from -shouldAutorotateToInterfaceOrientation: for all interface orientations. It should support at least one orientation.

chainprayer
Jul 24, 2010, 01:57 PM
Thanks for the video! Very helpful!

I am encountering an error for the - (void)moveBannerViewOffScreen section. The line that reads self.bannerview.frame = newBannerFrame; is returning an error that states "Request for member 'bannerview' is something not a structure or union." Any ideas on how to resolve this?

Thanks! :D

TuffLuffJimmy
Jul 24, 2010, 02:00 PM
I read the title as "Properly hiding Aids" and I thought "ehhhhh....?"

Thomas Harte
Jul 24, 2010, 02:49 PM
Thanks for the video! Very helpful!

I am encountering an error for the - (void)moveBannerViewOffScreen section. The line that reads self.bannerview.frame = newBannerFrame; is returning an error that states "Request for member 'bannerview' is something not a structure or union." Any ideas on how to resolve this?

Thanks! :D

That would imply that your class does not have an exposed getter for a member named bannerview. Replace self.bannerview with whatever means provides you with the ADBannerView object; if you've placed it in Interface Builder rather than created it programmatically it'll be the associated outlet (or you'll need to create one). Exactly the same as for talking to any other view.

DennisVar
Jul 27, 2010, 02:53 AM
One other gotcha is that you must make sure that the class with the didFailToReceiveAdWithError method is a delegate for your iAd banner view.

You can do this in Interface Builder by making the appropriate attachment, or do something like this in your code:


self.bannerView.delegate = self;


The code above assumes that didFailToReceiveAdWithError is placed in the same view controller that has your banner view, of course.