Tyler
Tyler

Reputation: 3

Xcode Code Problem - iAd

Ok so i keep getting this in my console.

2011-08-22 11:51:23.598 Binary Decode[5124:207] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=3 "The operation couldn’t be completed. Ad inventory unavailable" UserInfo=0x57379a0 {ADInternalErrorCode=3, NSLocalizedFailureReason=Ad inventory unavailable}

here is my code for the iAd.

this is my .h file

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
#import <iAd/ADBannerView.h>

@interface Binary_DecodeViewController : UIViewController  <ADBannerViewDelegate>  {

BOOL bannerIsVisible;
ADBannerView *aBanner;

}
- (IBAction)gotoLevel1:(id)sender;
- (IBAction)howtoplay:(id)sender;
- (IBAction)about:(id)sender;
- (IBAction)tryBinary:(id)sender;

@property (nonatomic,assign)BOOL bannerIsVisible;
@property (nonatomic,retain)IBOutlet ADBannerView *aBanner;

@end

here is my .m

@synthesize aBanner, bannerIsVisible;

 -(void)bannerViewDidLoadAd:(ADBannerView *)banner {
       if (!self.bannerIsVisible) {
       [UIView beginAnimations:@"animatedAdBannerOn" context:NULL];
       banner.frame = CGRectOffset(banner.frame, 0.0, 50.0);
       [UIView commitAnimations];
       self.bannerIsVisible = YES;
       banner.delegate=self;
     }
 }

 -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
        if (!self.bannerIsVisible) {
        [UIView beginAnimations:@"animatedAdBannerOff" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0.0, -320.0);
        [UIView commitAnimations];
        self.bannerIsVisible = NO;
        [banner setDelegate:self]; 
      }
 }

My main problem is no ad is showing up. Any help right now would be helpful.

Upvotes: 0

Views: 1799

Answers (2)

To fix the error, either right-click or ctrl-click on the AdBannerBiew in your xib/storyboard, and then drag the blue line that appears to your view controller icon (Its the yellow circle with a white square in it underneath your view controller in your xib/storyboard). Then click on 'delegate' when you release the mouse over the view controller icon.

Upvotes: 0

JonasG
JonasG

Reputation: 9324

You need to add some code to viewDidLoad, including

adView.delegate = self;
[self.view addSubview:adView];
bannerIsVisible = NO;

but you need to add even more, i don't know all of it. here is a good tutorial, just watch it and copy the code, it works fine: http://www.youtube.com/watch?v=cM9DqJmj45g

Upvotes: 1

Related Questions