2014-08-31 79 views
0

我試圖從viewcontrollerA調用viewcontrollerB用下面的代碼:崩潰調用視圖控制器實現SpriteKit現場

ViewControllerB *vc = [[ViewControllerB alloc]initWithNibName:nil bundle:nil]; 
[self presentViewController:vc animated:YES completion:nil]; 

內viewcontrollerB我有以下代碼:

SKView * skView = (SKView *)self.view; 

skView.showsFPS = NO; 
skView.showsNodeCount = NO; 

// Create and configure the scene. 
SKScene * scene = [MainScene sceneWithSize:skView.bounds.size]; 
//scene.scaleMode = SKSceneScaleModeAspectFit; 

// Present the scene. 
[skView presentScene:scene]; 

我收到錯誤:

[UIView setShowsFPS:]:無法識別的選擇器發送到實例

所以我已閱讀並實施該解決方案在以下鏈接中寫道:

Simple Sprite Kit Scene setup going wrong

但我有同樣的錯誤。

回答

0

我已經用下面的代碼解決:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil]; 
ViewControllerB *viewController = [storyboard instantiateViewControllerWithIdentifier:@"ViewControllerB"]; 
[self presentViewController:viewController animated:YES completion:nil]; 
1

當你做到這一點...

SKView * skView = (SKView *)self.view; 

skView.showsFPS = NO; 

......你告訴編譯器,你的看法是SKView但顯然事實並非如此。錯誤消息說這是一個普通的UIView。你需要看看MSPageViewControllerB是如何定義的,以及view屬性被定義爲什麼類型的對象。

相關問題