我Ad
view
在我的App
. 我的Ad view
(我正在使用 Google 的 adMob)中有一个“x”(退出)图像。
正常加载后Ad
一切正常。但是当出现错误并且Ad
无法加载我想显示自己的Ad
时,我实现了以下方法:
- (void)adView:(GADBannerView *)bannerView
didFailToReceiveAdWithError:(GADRequestError *)error{
cloaseView.userInteractionEnabled = YES;
shibbyAdImage.hidden = NO;
NSLog(@"Failed to load Ad with error : %@", error);
}
出于某种原因,userInteractionEnabled
未设置为是...
只是一些可能有帮助的代码:
这被称为加载Ad
-
-(void)googleAd{
// Create a view of the standard size at the bottom of the screen.
// Available AdSize constants are explained in GADAdSize.h.
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeMediumRectangle];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
//[bannerView_ setDelegate:self];
bannerView_.delegate = self;
// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
NSLog(@"in googleAd");
}
并放置Ad
-
- (void)adViewDidReceiveAd:(GADBannerView *)bannerView {
[UIView beginAnimations:@"BannerSlide" context:nil];
bannerView.frame = CGRectMake(
self.view.frame.size.width/2 -
bannerView.frame.size.width/2,
self.view.frame.size.height/2 -
bannerView.frame.size.height/2,
bannerView.frame.size.width,
bannerView.frame.size.height);
[UIView commitAnimations];
// NSLog(@"in adViewDidReceiveAd");
// NSLog(@"adpoint x: %g y: %g",adPoint.x, adPoint.y);
cloaseView.userInteractionEnabled = YES;
}