Results 1 to 4 of 4

Implementing iAd Code Snippet

This is a discussion on Implementing iAd Code Snippet within the Code Snippets forums, part of the iPhone/iPad Programming Tutorials category; 1) import the iAd framework in your project then add this code to your viewcontroller.h file: Code: #import <iAd/ADBannerView.h> 2) ...

          
   
  1. #1
    The Man Behind It All Fahad's Avatar
    Join Date
    Jun 2009
    Posts
    813

    Default Implementing iAd Code Snippet

    1) import the iAd framework in your project then add this code to your viewcontroller.h file:

    Code:
    #import <iAd/ADBannerView.h>
    2) In your viewcontroller.m file:

    Code:
    - (void)viewDidLoad {
        [super viewDidLoad];
    	
    	ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    	adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
    	adView.delegate = self; //*********incredibly important*************//
    	adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifier320x50,
    											 ADBannerContentSizeIdentifier480x32,
    											 nil];
    	CGRect myRect = CGRectMake(0, 0, 320, 50);				
    	adView.frame = myRect;
    	adView.hidden = YES;
    	adView.userInteractionEnabled = NO;
    	
    	
    }
    
    - (void)bannerViewDidLoadAd:(ADBannerView *)adView 
    {	
            //needed to remove iAd if there isn't any iAds there, required by Apple.
    	adView.userInteractionEnabled = YES;
    	adView.hidden = NO;
    	[self.view addSubview:adView];
    	
    }
    That's it



    MozyMac Founder,Chairman and CEO

    MacBook Pro Unibody late 2008 2.4Ghz 4GB ram 250GB HD

    MozyMac Youtube Channel

  2. #2
    Junior Member
    Join Date
    Aug 2010
    Posts
    1

    Default Problem

    I used this piece of code and recieved a warning that would crash my app when the add wasnt present.

    on the line:

    adView.delegate = self;
    //I got a warning that says : Class 'RootViewController' does not implement the 'ADBannerViewDelegate' protocol.

    I'm confused on what this means

    Thanks
    Scientific

  3. #3
    Junior Member Creegan's Avatar
    Join Date
    Oct 2010
    Location
    Heredia, Costa Rica
    Posts
    2

    Default

    That's exactly your problem, you need to add the "ADBannerViewDelegate" sentence to your RootViewController header, for example, if your RootViewController implements the UITableViewController you just need to add it next to the UITableViewController
    Code:
    @interface RootViewController : UITableViewController <ADBannerViewDelegate> {
    …

  4. #4
    Junior Member
    Join Date
    Jan 2012
    Location
    USA
    Posts
    1

    Default I like this place :)

    this is kinda cooo0ool

    I'm Rob, im new here! hello


    ___________________________________
    New York Recording Studio ????

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •