我不明白为什么我不行。
用例:
没有错误输出。
代码控制器:
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showParam) name:kNotificationShowParam object:nil];
//...
SKView * skView = (SKView *)self.view;
SKScene * scene = [[MenuScene alloc ]initWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:scene];
}
- (void)showParam
{
ParamViewController *ParamView = [[crazyButterflyParamViewController alloc]init];
[self presentViewController: ParamView animated: YES completion:^ {
}];
}
Code ParamController:
//method on button
-(void)goToMenu
{
[self.view.window.rootViewController dismissViewControllerAnimated:YES completion:^{
}];
}
Code MenuScene:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch* touch in touches)
{
if ([_button containsPoint:[touch locationInNode:_button.parent]])
{
SKTransition *transition = [SKTransition fadeWithDuration:0.4];
SKScene *scene = [[GameScene alloc] initWithSize:self.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[self.scene.view presentScene:scene transition:transition];
break;
}
if ([_buttonParam containsPoint:[touch locationInNode:_buttonParam.parent]])
{
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationShowParam object:nil];
break;
}
}
}
答案 0 :(得分:0)
现在好了!
我已通过菜单场景中的调用替换了通知:
if ([_buttonParam containsPoint:[touch locationInNode:_buttonParam.parent]])
{
//[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationShowParam object:nil];
[self.view.window.rootViewController presentViewController:_paramController animated: YES completion:^(void) {
SKView * skView = (SKView *)self.view;
MyScene *MenuScene = [[MyScene alloc]initWithSize:skView.bounds.size];
MenuScene.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:MenuScene];
}];
break;
}
有了这个,我可以在完成后找到原始控制器。