我试过检查其他相关问题,但它不成功。我正在关注位于here的示例代码。该程序成功运行在我的iPhone上,但是当我第一次调用广告时,它会挂在self.interstitial = [[GADInterstitial alloc] init]; 。没有错误消息,它只是突出显示上面的那一行而停止运行。我曾尝试在GameViewController和我的实际精灵套件场景中运行它。任何帮助,将不胜感激。我下载的示例项目运行良好。Spritekit插页式AdMob ios8
GameViewController.h
@property (strong,nonatomic) GADInterstitial *interstitial;
-(void)createAndLoadInterstitial;
-(void)loadAd;
GameViewController.m
- (void)createAndLoadInterstitial {
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.adUnitID = @"ca-app-pub-9726509502990875/8489925949";
self.interstitial.delegate = self;
GADRequest *request = [GADRequest request];
// Request test ads on devices you specify. Your test device ID is printed to the console when
// an ad request is made.
request.testDevices = @[ GAD_SIMULATOR_ID, @"MY_TEST_DEVICE_ID" ];
[self.interstitial loadRequest:request];
}
-(void)loadAd {
if (self.interstitial.isReady) {
[self.interstitial presentFromRootViewController:self];
} else {
[[[UIAlertView alloc] initWithTitle:@"Interstitial not ready"
message:@"The interstitial didn't finish loading or failed to load"
delegate:self
cancelButtonTitle:@"Drat"
otherButtonTitles:nil] show];
}
}
GameScene.h
@property (nonatomic, strong) GameViewController *GameViewController;
GameScene.m
//this is in -(void)gameOver which is called on contact call in -(void)didBeginContact
self.GameViewController = [[GameViewController alloc] init];
[self.GameViewController createAndLoadInterstitial];
[self.GameViewController loadAd];
你如何在skscene叫广告?我必须看到你的代码寻求帮助。 – 2014-12-10 23:19:57
你不能从SKScene这样调用。尝试使用cocos2d示例代码,在以下示例中已经可以使用cocos2d。 – 2014-12-10 23:29:21