ios6.0下使用iad
(1):加上iAd框架
在项目设置里的Build Phases的Link Binary With Libraries,加上iAd.Framework。
(2):在xib界面里拖入一个ADBannerView
(3)修改ViewController的.h文件
加入#import <iAd/iAd.h>,并且加入委托 @inte易做图ce ViewController : UIViewController<ADBannerViewDelegate>
在下面加入代码:
{
IBOutlet ADBannerView *adView;
BOOL bannerIsVisible;
}
@property (nonatomic, retain) ADBannerView *adView;
@property (nonatomic,assign)BOOL bannerIsVisible;
(4) 修改ViewController的.m文件
在@implementation ViewController下面加入@synthesize adView; @synthesize bannerIsVisible;
在- (void)viewDidLoad中加入self.adView.delegate = self;
并加入iad的两个方法:
-(void) bannerViewDidLoadAd:(ADBannerView *)banner
{
if(!self.bannerIsVisible)
{
[UIViewbeginAnimations:@"animateAdBannerOn" context:NULL];
banner.frame = CGRectOffset(banner.frame,0, -100);
[UIViewcommitAnimations];
self.bannerIsVisible =YES;
}
}
-(void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if(self.bannerIsVisible)
{
[UIViewbeginAnimations:@"animateAdBannerOff" context:NULL];
banner.frame = CGRectOffset(banner.frame,0, 100);
[UIViewcommitAnimations];
self.bannerIsVisible =NO;
}
}
补充:移动开发 , IOS ,