iOS Integration with iAD | Novice Tutorial
Novice Tutorial -- Learning Technology and Dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
iOS Tutorial
iOS Tutorial iOS Introduction iOS Environment Setup Objective C Basics Create Your First iPhone Application iOS Actions and Outlets iOS - Delegates iOS UI Elements iOS Accelerometer iOS Universal Applications iOS Camera Management iOS Location Operations iOS SQLite Database iOS Sending Email iOS Audio and Video iOS File Handling iOS Map Development iOS In-App Purchase iOS Integration with iAD iOS GameKit iOS Storyboards iOS Auto Layouts iOS Twitter and Facebook iOS Memory Management iOS Application Debugging
iOS In-App Purchase iOS GameKitIOS iAD Integration
Introduction
IAD is an advertising platform launched by Apple that can help developers generate revenue from applications.
Example Steps
- Create a simple View based application
- Select the project file, then select the target, then select frameworks and add iAd.framework.
- Update ViewController.h as shown below
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface ViewController : UIViewController<ADBannerViewDelegate>
{
ADBannerView *bannerView;
}
@end
- Update ViewController.m as shown below
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
;
bannerView = [initWithFrame: CGRectMake(0, 0, 320, 50)];
// Optional to set background color to clear color
[bannerView setBackgroundColor:];
[self.view addSubview: bannerView];
}
- (void)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
Run the application and get the following output:
YouTip