views:

1349

answers:

3

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.

[QUOTE]

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:

 - (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?

EDIT: Main viewcontroller Code as requested by a poster

    //
//  MainViewController.m
//  GBSoundboard4
//
//  Created by David Clarke on 19/06/2010.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "MainViewController.h"
#import <AVFoundation/AVAudioPlayer.h>

@implementation MainViewController
-(IBAction)goodafternoon {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"goodafternoon" ofType:@"wav"];
    AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
    [theAudio play];
}

-(IBAction)jollygood {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"jollygood" ofType:@"wav"];
    AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
    [theAudio play];
}
-(IBAction)playSound {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"goodmorning" ofType:@"wav"];
    AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];

    [theAudio play];
}

-(IBAction)upgrade {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/gb/app/the-great-british-soundboard/id376263018?mt=8"]];
}



/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {

    [self dismissModalViewControllerAnimated:YES];
}


- (IBAction)showInfo:(id)sender {    

    FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
    controller.delegate = self;

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:controller animated:YES];

    [controller release];
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc. that aren't in use.
}


- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/


- (void)dealloc {
    [super dealloc];
}


@end
+1  A: 

What you need to do is this event - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)

Is make your view that is with the bannerView cover up the banner by resizing its frame to cover the bannerView space on your screen and move the origin of the bannerView frame outside the screen

B then on - (void)bannerViewDidLoadAd:(ADBannerView *)banner

resize your view to make room for the BannerView and move the origin of the bannerView frame back to the space on the screen.

Robert Redmond
Do appreciate the advice, but can you help with being a little bit more specific with what goes where? That's the bit I'm struggling with most, I appreciate the concept that I'm essentially shoving the AdBannerView out of the way if there's no ad and pulling it back if there is one, I just can't fathom where to put the code to do this.
David26th
I can't assist further unless you show me your view controller code that controls your view and the bannerView.
Robert Redmond
I'd be fine with that, just give me a minute.
David26th
There it's up there now lol.
David26th
A: 

You need to do exactly what they describe. First, you need to make your MainViewController the delegate for your ADBannerView instance. Then, just copy and paste the code they've handed you into your MainViewController's implementation. This assumes that your banner appears at the bottom of the screen. If it appears at the top, reverse the direction of animation in the code they've provided.

If your banner fails to load an ad (which it will do until July 1 when the service goes live, and even after that if not attached to the network or if inventory drops), this delegate method will be called. Additionally, you can respond to other delegate callbacks that are described in the ADBannerViewDelegate protocol.

As they suggest, this is covered in the appropriate section of the iAd Programming Guide.

Brad Larson
Right I just need to clarify the steps on this as I'm still not getting the expected results.In IB Ctrl click on the ad banner and link the delegate 'ring' to Files Owner.Then back in Xcode paste the code snippet given into the appropriate viewcontroller.m fileThis gives me five error messages, if I try the same in the .h file it only gives two but I'm rather afraid I'm just being dim here...first time I've had to do anything like this. The rest of the app runs fine and could happily go to release but the Ads offer a way to monetize it without charging for the app itself.
David26th
@David26th - Without being too harsh, it sounds like you aren't very familiar with Cocoa and Objective-C in general, so I'd spend a little more time acclimating yourself to the platform before leaping into submitting an application for the App Store. A little extra understanding can lead to greater polish, and therefore a better user experience. In particular, I'd read the Cocoa Fundamentals Guide: http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/Introduction.html , especially the section on delegates.
Brad Larson
@David26th - What they've provided to you is the implementation of a delegate method. Without a description of what errors you are getting on compilation when you place this method implementation in MainViewController.m, it will be nearly impossible for us to help you. You may need to indicate that your MainViewController conforms to the ADBannerViewDelegate protocol, and link in the iAd framework, but beyond that I can't guess what might be going wrong.
Brad Larson
+1  A: 

There is a GREAT example of how to implement this in WWDC 2010 session video 112. If you are enrolled in the iPhone developer program, you can download it from iTunes University, as described below.

Assuming you are in the Apple Developer Program, you received an Email entitled "WWDC for everyone." Follow the links in that Email until you get to iTunes University. Then follow the link for frameworks, and pick session 112. I think the implementation is at approximately the 25 minute mark.

William Jockusch
you would rather give a solution than this kind of general info
sfa
General info or not this gives the exact answer. Brilliant.
David26th