我在iPhone应用程序中整合了iAd时遇到了问题 - 广告效果不佳时(请参阅http://www.clingmarks.com/iAd1.png和http://www.clingmarks.com/iAd2.png),但当我关闭它时,会留下白色空白屏幕(见http://www.clingmarks.com/iAd3.png)。我无法弄清楚为什么。下面是我如何整合广告:iAd在关闭后留下白色空白屏幕
因为我需要为iPhone操作系统的较低版本支持其他的广告,我的应用程序,其视图控制器是AdViewController的顶部添加一个容器视图。加载视图时,我通过编程方式创建AdBannerView,并将其作为子视图添加到AdViewController.view中。这里是viewDidLoad方法的代码:
Class adClass = (NSClassFromString(@"ADBannerView"));
if (adClass != nil) {
iAdView = [[ADBannerView alloc] initWithFrame:CGRectZero];
iAdView.frame = CGRectOffset(iAdView.frame, 0, -50);
iAdView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
iAdView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
iAdView.delegate = self;
iadViewIsVisible = NO;
[self.view addSubview:iAdView];
} else {
// init google adsense
}
以下是委托方法:
enter code here
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (!iadViewIsVisible) {
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// banner is invisible now and moved out of the screen on 50 px
banner.frame = CGRectOffset(banner.frame, 0, 50);
[UIView commitAnimations];
iadViewIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (iadViewIsVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// banner is visible and we move it out of the screen, due to connection issue
banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
iadViewIsVisible = NO;
}
}
你可以帮我在这http://stackoverflow.com/questions/5953418/implementation-for-iad – ajay 2011-05-11 07:28:03