iAD视图在广告关闭时冻结 [英] iAD View Freezes On Ad Close

查看:78
本文介绍了iAD视图在广告关闭时冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,因此在模拟器上进行测试后,事实证明此问题仅在实际设备上发生.如何解决此问题?


我正在用SpriteKit制作一个iOS应用,并正在实现iAD.除了一件事,一切都或多或少像我期望的那样工作.当我点击广告时,它会按预期将我带到全屏广告,但是当我关闭该广告时,当前视图将冻结,因为视觉上没有任何反应.我知道该应用程序仍在运行,因为当我再次单击横幅广告并再次将其关闭时,游戏恢复正常,并且游戏在视觉冻结的情况下进行了.这是在视图控制器类(iAD委托)中初始化横幅的方式:

Ok, so after testing on the simulators it turns out that this issue is only occurring on actual devices... How would I fix this?


I am making an iOS app with SpriteKit and am implementing iAD. Everything works more or less like I expect it too, except for one thing. When I tap on the ad, it brings me to a full screen ad, as expected, but when I close that ad the current view freezes, as in nothing happens visually. I know the app is still running because when I click the banner ad again and close out of it again the game returns to normal and the game had progressed while visually frozen. This is how the banner is initialized in my view controller class (the iAD delegate):

self.canDisplayBannerAds = YES;

CGRect bannerFrame = CGRectMake(0, 20, scene.size.width, 50);

banner = [[ADBannerView alloc] initWithAdType:ADAdTypeBanner];
banner.delegate = self;
banner.frame = bannerFrame;
[banner setAlpha:0];
[self.view addSubview:banner];

这些是加载方法,也在视图控制器类中:

And these are the loading methods, also in the view controller class:

- (void) bannerViewDidLoadAd:(ADBannerView *) bannerM
{
    NSLog(@"Ad Loaded");
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [bannerM setAlpha:1];
    [UIView commitAnimations];
}

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

我不是很了解这个问题,也不知道为什么会发生...任何帮助,我们将不胜感激!

I don't really understand the problem or why it is happening... Any help would be appreciated!

谢谢,
约书亚(StrongJoshua)

Thanks,
StrongJoshua

EDIT 以下是横幅广告打开和关闭时调用的两种方法:

EDIT Here are the two methods that are called when the banner ads open and close:

- (BOOL) bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
    if(playing)
    {
        NSLog(@"Ad Pause");
        SKView *v = (SKView *)self.view;
        NSLog(@"2");
        SKScene *s = (SKScene *)v.scene;
        NSLog(@"3");
        WBPlayScene *p = (WBPlayScene *) s;
        NSLog(@"4");
        [p.logic pause:YES];
        NSLog(@"Done");
    }
    return YES;
}

- (void) bannerViewActionDidFinish:(ADBannerView *)banner
{
    if(playing)
    {
        NSLog(@"Ad Unpause");
        [((WBPlayScene *)((SKView *)self.view).scene).logic pause:NO];
    }
}

已修复 所有这些NSLogs的原因是,当我尝试暂停它时,游戏崩溃了.达到"2"后,游戏崩溃,因此在SKScene *s = (SKScene *)v.scene;.它给出错误[UIView scene]: unrecognized selector sent to instance,我不明白为什么... 解决方案:要解决此问题,我将self.view更改为self.originalContentView,并得到了SKView而不是广告横幅的视图.

FIXED The reason for all those NSLogs is because the game crashes when I try to pause it. The game crashes after "2" is reached, so at SKScene *s = (SKScene *)v.scene;. It gives the error [UIView scene]: unrecognized selector sent to instance and I don't understand why... Solution: To fix this side issue I changed self.view to self.originalContentView and it got the SKView instead of the ad banner's view.

非常感谢您的帮助!

推荐答案

已解决:我不得不删除启用广告展示self.canDisplayBannerAds的呼叫,因为它干扰了我自己创建的横幅.

SOLVED: I had to remove the call to enable ad display self.canDisplayBannerAds because it interfered with my self-created banner.

这篇关于iAD视图在广告关闭时冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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