AdMob忽略了iPhone应用的if / else语句

时间:2015-01-27 01:25:37

标签: ios admob iad

我似乎已正确实现了iad / admob中介,因为它在viewDidLoad中有效。但是,在我的GameOver方法中,AdMob根本不关注if / else语句。

if (self.admobBannerView.hidden==YES) {


   self.bannerView = [[ADBannerView alloc] initWithFrame:CGRectMake(0.0f, 60.0f, 320.0f, 50.0f)];
    [self.bannerView setDelegate:self];
    [self.view addSubview:self.bannerView];
      [self.bannerView setAlpha:1];

    self.bannerView.hidden=NO;

}
else


    [self.bannerView setAlpha:0];
  self.bannerView.hidden=YES;

admobBannerView=[[GADBannerView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];


self.admobBannerView.adUnitID = @"unit-id0";
self.admobBannerView.rootViewController = self;
self.admobBannerView.delegate = self;


[self.view addSubview:self.admobBannerView];

GADRequest *request =[GADRequest request];

request.testDevices= @[ GAD_SIMULATOR_ID ];

[self.admobBannerView loadRequest:request];
 }

以上是我的GameOver方法,AdMob完全忽略它,只显示AdMob广告。 iAd永远不会在GameOver中播放。 AdMob不应该关注if / else语句吗?

1 个答案:

答案 0 :(得分:2)

if (self.admobBannerView.hidden==YES) {


   self.bannerView = [[ADBannerView alloc] initWithFrame:CGRectMake(0.0f, 60.0f, 320.0f, 50.0f)];
    [self.bannerView setDelegate:self];
    [self.view addSubview:self.bannerView];
      [self.bannerView setAlpha:1];

    self.bannerView.hidden=NO;

}
else


    [self.bannerView setAlpha:0];
  self.bannerView.hidden=YES;

这与:

相同
if (self.admobBannerView.hidden==YES) {


   self.bannerView = [[ADBannerView alloc] initWithFrame:CGRectMake(0.0f, 60.0f, 320.0f, 50.0f)];
    [self.bannerView setDelegate:self];
    [self.view addSubview:self.bannerView];
      [self.bannerView setAlpha:1];

    self.bannerView.hidden=NO;

}
else
{
    [self.bannerView setAlpha:0];
}
  self.bannerView.hidden=YES;