Create By: Osama Sheikh
(S.E) And I,T Expert
_________________________________
Post By: Hanan Mannan
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------
(S.E) And I,T Expert
_________________________________
Post By: Hanan Mannan
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------
iOS - iAd Integration
Introduction
iAd is used for display ads served by the apple server and helps us in earning revenue from the application.
Steps Involved
1. Create a simple View based application.
2. Select your project file, then select targets and then add iAd.framework in choose frameworks.
3. Update ViewController.h as follows.
#import <UIKit/UIKit.h> #import <iAd/iAd.h> @interface ViewController : UIViewController<ADBannerViewDelegate> { ADBannerView *bannerView; } @end
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
Now when we run the application we'll get the following output.




0 comments:
Post a Comment