Sprite Kit中的iAd暂停了场景 [英] iAd in Sprite Kit Pauses the scene

查看:52
本文介绍了Sprite Kit中的iAd暂停了场景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在实施iAd横幅广告时遇到问题,一切正常,直到轻按横幅广告,横幅广告导航正常.

I have a problem implementing iAd banner, everything works fine until the banner is tapped, the banner navigation works fine.

当我关闭添加Sprite kit场景时,就像冻结的场景一样,更新方法正在工作,因为我可以看到NSLog在那....但是一切都和点击添加之前的状态一样,即使我点击,没有任何效果,或者至少没有显示...

When i close the add the Sprite kit Scene is like frozen, update method is working because i can see the NSLog's there....but everything is just as it was before tapping the add, even if i tap , nothing works or at least its not being showed...

所以我的问题是关闭添加后如何恢复"游戏,iAd使用某种self.view.paused = YES;吗?

So my question is How to "resume" the game after closing the add, iAd uses some kind of self.view.paused = YES; ?

即使在苹果文档方面,我也读了很多书,但是我找不到他们暂停"我的游戏的方式,在这里我向您展示iAD的实现,我猜这太差了..

I've been reading a lot, even at apple documentation but i can't find the way they "pause" my game, here i show you the implementation of iAD which is so poor i guess..

@implementation GoViewController

- (void)viewDidLoad
{
    [super viewDidLoad];


    skView = (SKView *)self.view;
    //skView.showsFPS = YES;
    //skView.showsNodeCount = YES;

    // Create and configure the scene.
    scene = [GoMyScene sceneWithSize:skView.bounds.size];
    scene.scaleMode = SKSceneScaleModeAspectFill;

    // Present the scene.
    NSLog(@"%@",skView);
    self.canDisplayBannerAds = YES;



    [skView presentScene:scene];
}

- (BOOL)shouldAutorotate
{
    return YES;
}
-(void)viewWillLayoutSubviews{

}
- (NSUInteger)supportedInterfaceOrientations
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    } else {
        return UIInterfaceOrientationMaskAll;
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}
- (BOOL)prefersStatusBarHidden {
    return YES;
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:1];
    [UIView commitAnimations];
    NSLog(@"ADD ON");

}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:0];
   // [UIView commitAnimations];
    NSLog(@"ADD OFFFFFFFF");

}



-(void)bannerViewActionDidFinish:(ADBannerView *)banner{

    NSLog(@"banner finished");
    //[self bannerViewActionShouldBegin:banner willLeaveApplication:YES];
    //[UIView setAnimationBeginsFromCurrentState:YES];


}
-(void)bannerViewWillLoadAd:(ADBannerView *)banner{
    NSLog(@"banner starting to show");

}

推荐答案

将self.canDisplayBannerAds与spritekit一起使用通常会出现问题.我已经竭尽全力使它工作,但无济于事.相反,我使用以下代码:

There is usually a problem when using self.canDisplayBannerAds with spritekit. I have tried endlessly to get it to work, but to no avail. Instead, I use this code:

adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.delegate = self;
[adView setFrame:CGRectMake(0, 0, 1024, 768)]; // set to your screen dimensions
[adView setBackgroundColor:[UIColor clearColor]];
[self.view addSubview:adView];

首先在Viewcontroller的界面文件中初始化ADBannerView * adView变量,然后可以在ViewDidLoad方法中使用以上代码.

First initialize a ADBannerView *adView variable in your Viewcontroller's interface file, then you can use the above code in your ViewDidLoad method.

它非常适合我,并且在点击广告后,在屏幕暂停或无响应方面没有任何问题.

It works perfectly for me, and doesn't have any issues with pausing or unresponsive screen after clicking the ad.

这篇关于Sprite Kit中的iAd暂停了场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆