iAd tutorial for iOS: How To Integrate iAd into iPhone App

iAd tutorial will help you how to get revenue from apple ad service. It also help you to teach you how to integrate iAd to the iOS application in an effective way that you can generate a stable income. So let’s get started

iAd Promo

 

Introductions to iAd

It is a powerful ad’s service provided by apple for integrating ads in iOS platforms. With the help of iAd the advertisers can easily publish their ads to the entire world in an effective way. After the release of iOS SDK 4 onwards iAd frame work is available in the apple platform. So i am just thinking that to write a tutorial to demonstrate how we can integrate iAd into your iPhone app.

After going through this iAd tutorial, you will learn how to implement the iAd in a good way. That means you will deal with almost all major complex tasks that you are going to face in the real world iPhone app development. This sample tutorial consist of

  • Supporting both Portrait and Landscape.
  • Integrating  into the Universal app.
  • Implementing  with Story Board with iOS 7.

before going to the tutorial, you can take a look at the apple developer site

also you can take a look at the Framework reference provided by apple.

Major steps involved in Integration

1. Create a single view based universal application with named “iAdsDemo”

iAd Demo project Setup

 
iAd project View
2. Next you need to add the iAd.framework to the demo project. For that just go to Build Phases and Choose link Binary with the Libraries option. press + button and add iAd framework from the list.
iAd framework adding

3.Now we need to add some code in for enabling the ad network in the project.
Lets Update the SSViewController.h. import iAd.h and import ADBannerViewDelegate

@interface SSViewController : UIViewController

@end

Next we need to update the SSViewController.m with the following code

@interface SSViewController (){
    
    IBOutlet ADBannerView *topAdBanner;
}

@end

@implementation SSViewController


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


#pragma mark - iAdBanner Delegates

-(void)bannerView:(ADBannerView *)banner
didFailToReceiveAdWithError:(NSError *)error{
    NSLog(@"Error in Loading Banner!");
}

-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
    NSLog(@"iAd banner Loaded Successfully!");
}
-(void)bannerViewWillLoadAd:(ADBannerView *)banner{
    NSLog(@"iAd Banner will load!");
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner{
    NSLog(@"iAd Banner did finish");
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

4. Now don’t forget to hook up with the outlet with the Corresponding iAd Banner view.
5. now it is the time to run the application
iAd Simulator view
now the ads seems running on the simulator in the portrait mode. next we need to change the orientation of the device. oops! Something is Missing!. How we can fix the size of the banner ? it is the time to think about the AutoLayout in iOS.
6. Fixing the Layout issue of iAd Banner with the Help of AutoLayout property of iOS. We need to add some constraints for auto Layout position.Such as Horizontal space and Vertical space.

you are done. just run the application now.
iAd Landscape view

you can download the sample project from here.

10 Comments

  1. Samson October 7, 2013
  2. SiennaAmelia October 8, 2013
  3. Samson November 29, 2013
  4. safilsunny November 30, 2013
  5. safilsunny November 30, 2013
    • SiennaAmelia December 2, 2013
  6. Guest January 29, 2014
  7. Guest January 29, 2014
  8. XYZ January 29, 2014
  9. abc February 7, 2014

Leave a Reply

Your email address will not be published. Required fields are marked *