简体   繁体   English

Spritekit中的UIImagePickerController

[英]UIImagePickerController in Spritekit

I am trying to import an image into a Spritekit scene. 我正在尝试将图像导入Spritekit场景。 Using Xcode version 8.2 (8C38) with Swift 3. The code below work fine in a single view application but not with Spritekit. 在Swift 3中使用Xcode版本8.2(8C38)。下面的代码在单视图应用程序中可以正常使用,但在Spritekit中则不能。

    class GameScene: SKScene, UIImagePickerControllerDelegate, UINavigationControllerDelegate

    let imagePickerController = UIImagePickerController()

    imagePickerController.sourceType = .photoLibrary

    imagePickerController.delegate = self

    present(viewController, animated: false, completion: nil)

getting the following error 得到以下错误

    GameScene.swift:93:9: Use of unresolved identifier 'present'

cannot find 'present' under self or self.view either, i know in previous versions of swift we use to have presentViewController. 我也无法在self或self.view下找到“ present”,我知道在以前版本的swift中,我们曾经使用presentViewController。

You can't invoke present on a GameScene object. 您不能调用GameScene对象上的present

Instead you need to invoke present on a reference to GameViewController . 相反,您需要在对GameViewController的引用上调用present。

And you can find the instructions to retrieve a reference to your GameViewController here . 您可以在此处找到有关检索对GameViewController的引用的说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM