2014-02-25 82 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