2014-02-25 30 views
0

所以,当我的视图控制器负载我开始发送adBanner请求..暂停iAd的请求发出

- (void)viewDidLoad{ 

    [super viewDidLoad]; 

    self.canDisplayBannerAds = YES; 

} 

但是从我的场景时,我的比赛,即使我设置canDisplayBannerAds为NO,我得到一个错误... 我已作了评论错误调试通过

- (IBAction)startGame:(id)sender { 

    NSLog(@"Start Game triggered"); 
    adBanner.hidden = 1; 
    self.canDisplayBannerAds = NO; 

    // Configure the view. 
    // Configure the view after it has been sized for the correct orientation. 
    skView = (SKView *)self.view; 
    if (!skView.scene) { // the error happens during this if statement 
     skView.showsFPS = YES; 
     skView.showsNodeCount = YES; 

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

     theScene.delegate = self; 
     // Present the scene. 
     [skView presentScene:theScene]; 

    } 
} 

错误开始的:

终止应用程序由于未捕获的异常“NSInvalidArgumentException”,原因: ' - [UIView的场景]:无法识别的选择发送到实例0x16d252a0'

问题是什么?我该如何解决这个问题?

回答

1

您的视图控制器的self.view属性不是SKView,这是一个UIView。您可能已将广告横幅视图指定为视图控制器的视图,或者在同一视图控制器中使用iAd导致它替换SKView,或者您的Sprite Kit故事板文件不像使用SKView那样。

+0

你这是在更换SKView正确的,所以我增加了以下和Im现在好了。感谢那! skView =(SKView *)self.originalContentView; – 4GetFullOf