我在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