rac*_*ola 1 iphone objective-c iad
我想在我的应用中加入iAds.当有网络连接时它工作正常但是当网络不可用时iAds不会隐藏..请找到下面的代码并帮助我..谢谢你的时间..
我在viewDidLoad中包含了这段代码
static NSString * const kADBannerViewClass = @"ADBannerView";
if (NSClassFromString(kADBannerViewClass) != nil) {
if (self.adView == nil) {
self.adView = [[[ADBannerView alloc] init] autorelease];
self.adView.delegate = self;
self.adView.frame = CGRectMake(0,355,320,60);
self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
}
}
[self.view addSubview:self.adView];
Run Code Online (Sandbox Code Playgroud)
代表方法:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible) {
[UIView beginAnimations:nil context:NULL];
banner.frame = CGRectOffset(banner.frame, 0,10);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible) {
[UIView beginAnimations:nil context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, -10);
[UIView commitAnimations];
self.bannerIsVisible = NO;
NSLog(@"%@",error);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我正确理解您的代码,您最初会显示横幅.这是不正确的.最好先将横幅移出屏幕,然后只在收到时将其移动到屏幕上并在收到bannerViewDidLoadAd:后退回屏幕bannerView:didFailToReceiveAdWithError:.
这也有一个优点,即您的横幅视图最初不会显示为空.如果网络连接速度较慢,可能会发生这种情况.
| 归档时间: |
|
| 查看次数: |
889 次 |
| 最近记录: |