我正在尝试将 iAd 与我当前的 sprite 工具包项目集成。我已经搜索了现有的问题,其中大部分都说添加
self.canDisplayBannerAds = YES;
将使广告发挥作用。但是,每次我尝试发布的解决方案之一时,我都会收到此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setShowsFPS:]: unrecognized selector sent to instance 0x14dbcc50'
在 Storyboard 中,我尝试将 View 设置为 SKView。我已将 iAd 框架添加到项目中。
这是我的 viewWillLayoutSubviews 方法:
-(void)viewWillLayoutSubviews{
[super viewWillLayoutSubviews];
// Configure the view.
SKView * skView = (SKView *)self.view;
skView.showsFPS = NO;
skView.showsNodeCount = NO;
if(!skView.scene){
// Create and configure the scene.
SKScene * scene = [Intro sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[skView presentScene:scene];
self.canDisplayBannerAds = YES;
}
}
我该如何解决这个问题?感谢任何和所有建议!
编辑:
这是我的 Storyboard的屏幕截图,其中选择了 View 。我认为这就是如何使用 Storyboard更改 View 的类。但我仍然遇到同样的错误。
最佳答案
您不是因为横幅广告而崩溃。你快崩溃了
skView.showsFPS = NO;
因为 self.view 是 UIView 而不是 SKView。
编辑:
这似乎是使用 UIViewController 的 iAD 类别扩展的副作用。您可以使用以下方法检索 SKView:
SKView * skView = (SKView*)self.originalContentView;
关于ios - SpriteKit - iOS 7 - iAd 集成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24148045/