2014-08-31 80 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属性被定义为什么类型的对象。

相关问题