MikeAsp
MikeAsp

Reputation: 147

Could not instantiate class named ADBannerView

i am trying to inset an iad banner at the bottom of my app but keep getting errors after following tutorials. code as follows.

@interface DMKHomeViewController (UIViewcontroller ) <ADBannerViewDelegate>{

}
@end

@implementation DMKHomeViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

-(void)bannerViewDidLoadAd:(ADBannerView *)banner {

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1];

[banner setAlpha:1];

[UIView commitAnimations];

}



- (void)bannerView:(ADBannerView *)

banner didFailToReceiveAdWithError:(NSError *)error

{

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1];

[banner setAlpha:0];

[UIView commitAnimations];

}

i keep getting the following error * Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named ADBannerView' * First throw call stack:

Upvotes: 6

Views: 1995

Answers (2)

serge-k
serge-k

Reputation: 3512

Please make sure that you have added the "iAd.framework"...

To do this go to the "App. Target", "General" and scroll down until you see "Linked Frameworks and Libraries". Hit "+" and select the iAd framework. See screen captures below...

App. Target -> General

'+' to add, search for iAd

Upvotes: 20

Bhoomi Jagani
Bhoomi Jagani

Reputation: 2423

You have not created object of AdBannerview..

First, create object for banner view and set delegate for it.

-(void)ViewDidLoad
{
   [self createBannerView];
}
- (void)createBannerView {

  Class cls = NSClassFromString(@"ADBannerView");
  if (cls) {
    ADBannerView *adView = [[cls alloc] initWithFrame:CGRectZero];


    // Set the current size based on device orientation
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
    adView.delegate = self;

    adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin |
                              UIViewAutoresizingFlexibleRightMargin;

    // Set initial frame to be offscreen
    CGRect bannerFrame =adView.frame;
    bannerFrame.origin.y = self.view.frame.size.height;
    adView.frame = bannerFrame;

    self.bannerView = adView;
    [self.view addSubview:adView];
    [adView release];
  }
}

Upvotes: 0

Related Questions