I have implemented
ReplayKit in my SpriteKit game, but since everything is done within the GameViewController the record button appears too early. Please see my GameViewControllerclass below:class GameViewController: UIViewController, RPPreviewViewControllerDelegate{ var videoRecButton: UIButton! var videoRecImage: UIImage! override func viewDidLoad() { super.viewDidLoad() let skView = self.view as? SKView if skView?.scene == nil { skView?.showsFPS = true skView?.showsNodeCount = true skView?.showsPhysics = true skView?.ignoresSiblingOrder = false let posterScene = PosterScene(size: skView!.bounds.size) posterScene.scaleMode = .aspectFill skView?.presentScene(posterScene) } videoRecButton = UIButton(type: .custom) videoRecImage = UIImage(named:"videoRecButton.png") videoRecButton.frame = CGRect(x:0, y: 0, width: (videoRecImage?.size.width)!, height: (videoRecImage?.size.height)!) videoRecButton.setImage(videoRecImage, for: .normal) videoRecButton.addTarget(self, action:#selector(self.videoRecButtonClicked), for: .touchUpInside) self.view.addSubview(videoRecButton) } func videoRecButtonClicked() { print("Button Clicked") startRecording() } func startRecording() { let recorder = RPScreenRecorder.shared() recorder.startRecording{ [unowned self] (error) in if let unwrappedError = error { print(unwrappedError.localizedDescription) } else { self.videoRecButton.addTarget(self, action:#selector(self.stopRecording), for: .touchUpInside) } } } func stopRecording() { let recorder = RPScreenRecorder.shared() recorder.stopRecording { [unowned self] (preview, error) in self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .plain, target: self, action: #selector(self.startRecording)) if let unwrappedPreview = preview { unwrappedPreview.previewControllerDelegate = self self.present(unwrappedPreview, animated: true) } } } func previewControllerDidFinish(_ previewController: RPPreviewViewController) { dismiss(animated: true) } override var shouldAutorotate: Bool { return true } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { if UIDevice.current.userInterfaceIdiom == .phone { return .allButUpsideDown } else { return .all } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } override var prefersStatusBarHidden: Bool { return true }}- How can I call the
andstartRecording
functions from a class that inherits fromstopRecording
likeSKScene
class?GameScene - How can enable, disable and hide the
button from thevideoRecButton
class?GameScene