如何在SKScene中执行segue? [英] How to perform segue from within a SKScene?

查看:121
本文介绍了如何在SKScene中执行segue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试从精灵工具包SKScene层中执行一个segue。我的应用程序要求用户触摸场景中的图像,这会推高新的UIViewController。但是每次我尝试在SKScene游戏层内执行时,它都会给我输出没有带标识符错误的segue。我有一个segue并用标识符指定它。

I have been trying to perform a segue from within a sprite kit SKScene layer. My application requires the user to touch an image on the scene that would push up a new UIViewController. But every time I try to perform from within the SKScene game layer, it gives me output with has no segue with identifier error. I do have a segue and have specified it with an identifier.

我的简单问题是,如何运行SKScene游戏层?请帮帮我。

My simple question, how can one perfrom segue with a SKScene game layer running? Please help me out.

推荐答案

Segues属于视图控制器,不属于SpriteKit场景。如果要从SpriteKit节点的事件处理代码中执行segue,则需要查找拥有呈现场景的视图的视图控制器。例如,在 SKScene 子类' touchesBegan:withEvent:方法:

Segues belong to view controllers, not SpriteKit scenes. If you want to perform a segue from within a SpriteKit node's event handling code, you'll need to look up the view controller that owns the view presenting the scene. For example, in a SKScene subclass' touchesBegan:withEvent: method:

UIViewController *vc = self.view.window.rootViewController;
[vc performSegueWithIdentifier:@"id" sender:nil];

这篇关于如何在SKScene中执行segue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆