IOS: Integrated IAD

Source: Internet
Author: User

Integrate advertisements in iPhone programs, whether or not they can make money or not.

Refer to the following article:

Http://bees4honey.com/blog/tutorial/how-to-add-iad-banner-in-iphoneipad-app/

Refer to the integrating Iads into an iOS 4 iPad app (xcode 4) tutorial.

 

(1) Add the IAD framework

Link binary with libraries of build phases in the Project Settings, plus IAD. framework.

(2)

Drag an adbannerview in the xib Interface

(3) modify the. h file of viewcontroller

# Import <IAD/IAD. h>

Add Delegation

@ Interface myviewcontroller: uiviewcontroller <adbannerviewdelegate>

Add the output port

Iboutlet adbannerview * adview;

Bool bannerisvisible;

 

@ Property (nonatomic, retain) adbannerview * adview;

@ Property (nonatomic, assign) bool bannerisvisible;

 

 

(4) modify the. M file of viewcontroller

In the viewdidload method:

Adview. requiredcontentsizeidentifiers = [nsset setwithobject: adbannercontentsizeidentifierportrait];

Adview. currentcontentsizeidentifier = adbannercontentsizeidentifierportrait;

Adview. Delegate = self;

 

In the viewdidunload method:

Adview. Delegate = nil;

 

In addition:

To prevent iPhone network exceptions, IAD is a blank area when it cannot be displayed. you can do some work in these two methods.

-(Void) bannerviewdidloadad :( adbannerview *) banner

{

If (! Self. bannerisvisible)

{

[Uiview beginanimations: @ "animateadbanneron" context: NULL];

Banner. Frame = cgrectoffset (banner. Frame, 0,-100 );

[Uiview commitanimations];

Self. bannerisvisible = yes;

}

}

 

-(Void) bannerview :( adbannerview *) banner didfailtoreceiveadwitherror :( nserror *) Error

{

If (self. bannerisvisible)

{

[Uiview beginanimations: @ "animateadbanneroff" context: NULL];

Banner. Frame = cgrectoffset (banner. Frame, 0,100 );

[Uiview commitanimations];

Self. bannerisvisible = no;

}

}

Related Article

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.