iAd is used to show ads, provided by the apple company server. iAd helps us in making income from an iOS program.
iAd Integration – Steps Involved
Step 1. Create a simple view-based application.
Step 2. Select your project file, then select targets and then add iAd.framework in choose frameworks.
Step 3. Update ViewController.h as follows −
#import <UIKit/UIKit.h> #import <iAd/iAd.h> @interface ViewController : UIViewController<ADBannerViewDelegate> { ADBannerView *bannerView; } @end
Step 4. Update ViewController.m as follows −
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; bannerView = [[ADBannerView alloc]initWithFrame: CGRectMake(0, 0, 320, 50)]; // Optional to set background color to clear color [bannerView setBackgroundColor:[UIColor clearColor]]; [self.view addSubview: bannerView]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - AdViewDelegates -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{ NSLog(@"Error loading"); } -(void)bannerViewDidLoadAd:(ADBannerView *)banner{ NSLog(@"Ad loaded"); } -(void)bannerViewWillLoadAd:(ADBannerView *)banner{ NSLog(@"Ad will load"); } -(void)bannerViewActionDidFinish:(ADBannerView *)banner{ NSLog(@"Ad did finish"); } @end
Output
When we run the program, we'll get the following outcome −
1 comments :
Write commentsVery nice article with great content.
Replythank you for sharing this awesome blog with us.
keep updating....
ios online course
Emoticon Emoticon