0

で作成し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;
}
4

1 に答える 1

0

usrInteractionを最初に設定するときは、次のようにログに記録します。

cloaseView.userInteractionEnabled = YES;
NSLog(@"UserInteraction should now be on, its %d", cloaseView.userInteractionEnabled);

と同じ:

cloaseView.userInteractionEnabled = YES;

一部のビューがuserInteractionをブロックしているかどうかを確認するには、ビューチェーンを上に(スーパービューを上に)歩く必要がある場合があります。

これを使用してそれを行うことができます(ボタンを追加するか、すべてが正常であるはずのときにタイマーから呼び出すことによって:

@implementation UIView (Utilities)

+ (void)dumpSuperviews:(UIView *)v msg:(NSString *)msg
{
    NSMutableString *str = [NSMutableString stringWithCapacity:256];

    while(v) {
        [self appendView:v toStr:str];
        v = v.superview;
    }
    [str appendString:@"\n"];

    LTLog(@"%@:\n%@", msg, str);
}
+ (void)appendView:(UIView *)a toStr:(NSMutableString *)str
{
    [str appendFormat:@"  %@: frame=%@ bounds=%@ layerFrame=%@ tag=%d userInteraction=%d alpha=%f hidden=%d\n", 
        NSStringFromClass([a class]),
        NSStringFromCGRect(a.frame),
        NSStringFromCGRect(a.bounds),
        NSStringFromCGRect(a.layer.frame),
        a.tag, 
        a.userInteractionEnabled,
        a.alpha,
        a.isHidden
        ];
}

@end
于 2012-08-08T17:18:57.810 に答える