Their are so many third party ads SDK, Apple also provided ads with their own SDK. They bring iAd framework to Xcode that allows user to add ad functionality to their app and generate revenue. In this post, i am going to tell you how can we use iAd framework in our iOS apps.
Add iAd.framework to your project.Import
@interface TMAdView : UIViewController
Now select your .m file and in its viewDidLoad, allocate and initialise your ADBannerView instance.Give it frame(position in your screen )where you want to place ads.Set its delegate to self, as we need to adjust our layout if there is no ad(if we did not adjust our layout based on ad load and unload, there will be blank space if no ad is available for that region)and finally add it to our view as a subview.
ad = [[ADBannerView alloc]init];
ad.frame=CGRectMake(0,0, 320, 50);
Now. it’s time to implement our delegates, all our self explanatory as per their name and also line written in NSLog.
NSLog(@”Error in Loading Banner!”);
NSLog(@”iAd banner Loaded Successfully!”);
NSLog(@”iAd Banner will load!”);
NSLog(@”iAd Banner did finish”);
(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave