首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试实现ReplayKit时出现错误

尝试实现ReplayKit时出现错误
EN

Stack Overflow用户
提问于 2017-04-23 22:04:19
回答 1查看 219关注 0票数 0

我正在使用SpriteKit构建一个游戏。我正在尝试实现ReplayKit,但是我得到了一些错误。这是我正在使用的代码。

代码语言:javascript
复制
    func startRecording() {
    let recorder = RPScreenRecorder.shared()

    recorder.startRecording(withMicrophoneEnabled: true) { [unowned self] (error) in
        if let unwrappedError = error {
            print(unwrappedError.localizedDescription)
        } else {

        }
    }
}

func stopRecording() {
    let recorder = RPScreenRecorder.shared()

    recorder.stopRecording { [unowned self] (preview, error) in

        if let unwrappedPreview = preview {
            unwrappedPreview.previewControllerDelegate = self
            //Error in the line below
            self.present(unwrappedPreview, animated: true)
        }
    }
}


 func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
   //Error in the line below
    dismiss(animated: true)
 }

第一个错误是“GameScene类型的值没有成员”,第二个错误是“使用未解析的标识符清除”。

我做错了什么,我导入了ReplayKit并将RPPreviewViewControllerDelegate添加到了我的GameScene类中。

EN

回答 1

Stack Overflow用户

发布于 2017-04-23 23:04:14

presentdismiss函数都是UIViewController的实例方法。您的GameScene类显然不是从UIViewController继承的,这就是为什么这些函数对它的实例不可用的原因。你基本上是在试着调用一些根本不存在的东西。

尝试将您的代码移动到UIViewController实例。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43572139

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档