iAds总结

原文地址:http://blog.csdn.net/xiaoxuan415315/article/category/1239650


iAds是SDK4.0所出现的又一新特性,只要加入Apple的iAd Network,你就可以在程序中使用iAd为你的程序带来额外的收益。在此之前iPhone程序中的广告大多靠google ads实现,现在的SDK4.0的这一新特性又为我们在itunes store通过广告上获得收益提供了新的方法。


iAds的基本步骤
1.首先登陆你的Apple开发者ID。并且登陆到itunes connect签署同意条款。
2.完善你的contact,bank和tax信息,这时在你的itunes connect中就多了iAds管理这一项。
3.将iAd.framework添加到你的工程,并实现其代理。

使用方法
1.创建ADBannerView
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[self.view addSubview:adView];

2.广告点击效果设置(是否允许弹出广告,或是退出应用程序播放广告)返回YES为允许,willLeave表示广告是否会离开当前应用程序
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
    NSLog(@"Banner view is beginning an ad action");
    BOOL shouldExecuteAction = [self allowActionToRun]; // your application implements this method
    if (!willLeave && shouldExecuteAction)
    {
        // insert code here to suspend any services that might conflict with the advertisement
    }
    return shouldExecuteAction;
}

3.显示和隐藏广告
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    if (!self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
        // assumes the banner view is offset 50 pixels so that it is not visible.
        banner.frame = CGRectOffset(banner.frame, 0, 50);
        [UIView commitAnimations];
        self.bannerIsVisible = YES;
    }
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    if (self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
        // assumes the banner view is at the top of the screen.
        banner.frame = CGRectOffset(banner.frame, 0, -50);
        [UIView commitAnimations];
        self.bannerIsVisible = NO;
    }
}


ADBannerView 
原文

// This method is invoked each time a banner loads a new advertisement.
// Once a banner has loaded an ad, it will display that ad until another ad is available.
// The delegate might implement this method if it wished to defer placing the banner in a view        hierarchy until the banner has content to display.  
翻译 
// 当每次新加载一个广告横幅时调用此方法。
// 当一个广告条加载了一个广告横幅,它就会一直显示,直到新的广告横幅加载完成。
// 如果想让广告条在内容加载完成后才在层次结构的视图中显示出来,可以通过委托方式来实现此方法。

  - (void)bannerViewDidLoadAd:(ADBannerView *)banner;  


==================================================== 
原文
// This method will be invoked when an error has occurred attempting to get advertisement content. 
// The ADError enum lists the possible error codes.  
翻译
// 广告内容如果发生错误时,这个方法将被调用。
// 该ADError枚举列出了可能的错误代码。  


- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error;  
====================================================  


原文
// This message will be sent when the user taps on the banner and some action is to be taken.
// Actions either display full screen content in a modal session or take the user to a different application.
// The delegate may return NO to block the action from taking place, but this should be avoided if possible because most advertisements pay significantly more when the action takes place and, over the longer term, repeatedly blocking actions will decrease the ad inventory available to the application.
// Applications may wish to pause video, audio, or other animated content while the  advertisement's action executes.


翻译
//  当用户点击banner上或者采取了一些操作,这个信息被发送。
//  动作执行后,要么在一个模式会话内全屏显示,或者让用户切换到不同的应用程序中。 
//  这个委托方法可以返回NO来组织这些动作的发生,但是这应该尽量避免,因为大多数广告在动作明显发生时支付得更多,并且在较长的时间内,如果拦截动作多次出现的话,将减少广告资源提供给应用程序。 
//  当广告操作执行时,可能希望应用程序的视频,声音,或者其他的动画内容都暂停。  


- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave; 
===================================================  


原文
// This message is sent when a modal action has completed and control is returned to the          application. 
// Games, media playback, and other activities that were paused in response to the beginning of the action should resume at this point.

翻译
// 当一个行为模式完成后或者控制权返回给应用程序时发送一个信息。
// 通过该事件的响应开始从断点恢复游戏,媒体的播放,和其他的活动。

- (void)bannerViewActionDidFinish:(ADBannerView *)banner;



你可能感兴趣的:(iAds总结)