Easy use of IOS Adbannerview

Source: Internet
Author: User

IAD advertising is Apple's official advertising platform, and we can place iad ads on the iOS platform. There is a high gate for businesses that advertise in iad???? But the relative rewards for developers???? Better?????? Is that iad ad?? Countries with little??。

?? Advertising?????????? The same?? On the screen, on the screen?? A position?? A part?? Room.?? Point?????? When advertising, navigate to another app or?? Out modal???? To?? Details of the current advertisement. Point?? Off?? Advertising button, you can go back to the original?? 's screen.

* No matter what?? Screen or?? The case of the screen,???? ?????? of ads on different iOS devices Is?? Specific, as shown below.
?? * On iphone 4 and before device and ipod Touch 4th generation as well as device?? In case of screen,???? ???? of advertising Is 480x32.?? In iphone 5 and ipod Touch 5th generation?? In case of screen,???? ???? of advertising It's 568x32.
?? * On iphone and ipod touch?? In case of screen,???? ???? of advertising It's 320x50.
?? * on ipad?? In case of screen,???? ???? of advertising It's 1024x66.
?? * on ipad?? In case of screen,???? ???? of advertising It's 768x66.

So here are a few steps to using Adbannerview:

1. before using IAD,?? Need to introduce the IAD framework (iad.framework):

2. Initialize the Adbannerview method:

Self.bannerview=[[adbannerview alloc] Initwithframe:cgrectzero];    self.bannerview.currentcontentsizeidentifier=adbannercontentsizeidentifierportrait;//Current type    of banner self.bannerview.delegate=self;        Displays    self.bannerview.frame=cgrectoffset (self.bannerView.frame, 0, 0) below the parent window;      [Self.view AddSubview:self.bannerView];

Don't forget that Adbannerview has its own protocol method that needs to be implemented.

@interface viewcontroller:uiviewcontroller<uiscrollviewdelegate,adbannerviewdelegate>

3. How to create animations:

-(void) layoutanimated: (BOOL) animated{//In iOS 6, the banner is automatically adjusted//to support iOS 5.0 and below, you also need to set the currentcontentsizeidentifier// #if __iphone_os_version_min_required < __iphone_6_0//cgrect Contentframe = self.view.bounds;//if (contentF Rame.size.width < ContentFrame.size.height) {//Self.bannerView.currentContentSizeIdentifier =//Adbanner contentsizeidentifierportrait;//} else {//Self.bannerView.currentContentSizeIdentifier =//Adbannercont entsizeidentifierlandscape;//}//#endif cgrect bannerframe=self.bannerview.frame;//if (self.bannerView.userIn teractionenabled) {//To determine if the Bannerview is in the picture//} if (self.bannerView.bannerLoaded) {//To determine if the Adbanner is loaded successfully//set on the screen    Edge bannerframe.origin.y=0;    }else{//Set on the outside of the screen to make it hidden bannerframe.origin.y=-self.bannerview.frame.size.height;    } [UIView animatewithduration:animated?0.25:0.0 animations:^{_bannerview.frame=bannerframe; }];} #if __iphone_os_version_min_required < __iphone_6_0//-(BOOL) shouldautorotatetointerfaceorientation: (UIInterfaceOrientation) interfaceorientation//{//return yes;//}//#endif

4, the implementation of Adbannerview and Uiscrollerview agreement

-(void) Bannerviewdidloadad: (Adbannerview *) banner{    NSLog (@ "ad loading succeeded");    [Self layoutanimated:yes];} -(void) Bannerview: (Adbannerview *) banner didfailtoreceiveadwitherror: (Nserror *) error{    NSLog (@ "ad load Failed");    [Self layoutanimated:yes];} -(void) Bannerviewactiondidfinish: (Adbannerview *) banner{    NSLog (@ "advertising off");    [Self layoutanimated:yes];} #pragma mark uiscrollerview-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{    int page= Scrollview.contentoffset.x/scrollview.frame.size.width;        Self.pagecontroller.currentpage=page;}

Then the Adbannerview ad banner is basically complete, and the last one is attached:

Easy use of IOS Adbannerview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.