【问题标题】:how to present UIViewController from SKScene如何从 SKScene 呈现 UIViewController
【发布时间】:2014-09-26 18:16:23
【问题描述】:

通常当你从另一个 viewController 中展示一个 viewController 时:

let vc : UIViewController = storyboard.instantiateViewControllerWithIdentifier("viewController") as UIViewController;
self.presentViewController(vc, animated: true, completion: nil);

我想展示一个来自 SKScene 的 viewController。我还没有找到任何方法来做到这一点。 这个问题可能是重复的,但我刚刚在目标 C 中找到了对我没有意义的答案

【问题讨论】:

  • 很确定还有一些特定于 swift 的问题(有些甚至可能有答案),因为“如何从场景中访问视图控制器”、“如何从场景中呈现视图控制器”和类似的问题非常常见问题

标签: swift uiviewcontroller sprite-kit skscene


【解决方案1】:

在您的场景类中尝试以下操作:

var currentViewController:UIViewController=UIApplication.sharedApplication().keyWindow.rootViewController!

currentViewController.presentViewController(viewController, animated: true, completion: nil)

希望对你有帮助。

【讨论】:

  • 这行得通!谢谢!
猜你喜欢
  • 1970-01-01
  • 2014-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-20
  • 1970-01-01
  • 2013-10-26
相关资源
最近更新 更多