ios - 错误 : Use of undeclared type 'SCNView'

标签 ios swift storyboard scenekit

我正在从 Obj-C 过渡到 Swift,5 秒后我卡住了:/

  1. 我有一个带有 SCNView 对象的 Storyboard
  2. 我将连接拖到我的 View Controller
  3. Xcode 写出 @IBOutlet var scene: SCNView!

我得到错误:

'weak' cannot be applied to non-class type '<<error type>>'

Use of undeclared type 'SCNView'

这是什么?

我正在使用最新的 Xcode 6.3。

最佳答案

您需要使用 import 语句告诉 Swift 您打算在源代码文件中使用的框架(模块),就像您使用 #import#include

import SceneKit 

class MyViewController: UIViewController {
    @IBOutlet var sceneView: SCNView!
    // ...
}

这既使类、函数和其他符号可用于您的源文件,又使 Xcode 在构建您的应用程序时链接到 SceneKit 框架二进制文件中。

关于ios - 错误 : Use of undeclared type 'SCNView' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29533124/

相关文章:

ios - 如何混淆 cocoa touch 框架代码? ( swift 4)

iphone - UILocalNotification - 每天在特定时间触发并重复

ios - Swift 动态转换失败 UIPageViewController

swift - xCode、Swift : working with vs. 无需 Storyboard即可工作

ios - 多种异步方法,一个完成处理程序

ios - 我可以在不注册开发人员计划的情况下在 iPhone 上测试我的应用程序吗?

swift - 如何在 Swift 中检索对象的类型?

swift - iOS 10 : Custom UITabBar background image produces border at top of image. 如何删除它?

ios - 可能有一个 UINavigationController 用于不填充整个 super UIView 的 UITableView

ios - 如何在 swift 中全局声明 UIView?