我正试图用以下代码从viewcontrollerA调用viewcontrollerB:
ViewControllerB *vc = [[ViewControllerB alloc]initWithNibName:nil bundle:nil];
[self presentViewController:vc animated:YES completion:nil];
在视图控制器B中,我有以下代码:
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];
我收到错误:
[UIWiew setShowsFPS:]:无法识别的选择器已发送到实例
所以我已经阅读并实现了在以下链接中编写的解决方案:
简单精灵套件场景设置出错
但我也有同样的错误。
当您执行此操作时。。。
SKView * skView = (SKView *)self.view;
skView.showsFPS = NO;
您告诉编译器您的视图是SKView
,但显然不是。错误消息显示它是一个普通的UIView
。您需要了解MSPageViewControllerB
是如何定义的,以及它的view
属性定义为什么类型的对象。
我用以下代码解决了问题:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
ViewControllerB *viewController = [storyboard instantiateViewControllerWithIdentifier:@"ViewControllerB"];
[self presentViewController:viewController animated:YES completion:nil];