で作成しAd
view
ましたApp
。「x」(終了)画像がありますAd view
(GoogleのadMobを使用しています)。
が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
はyesに設定されていません...
役立つかもしれないもう少しのコード:
これは、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;
}