4

我使用重播工具包记录我的屏幕,当预览屏幕弹出时,有一个取消按钮来关闭屏幕,但它什么也没做。我有委托函数 previewControllerDidFinish 和代码来解除它,但它并没有消失。有谁知道按取消时如何关闭窗口?谢谢!

func previewControllerDidFinish(previewController: RPPreviewViewController) {
    print("Preview finish")

        // close preview window
        previewController.dismissViewControllerAnimated(true, completion: nil)
    }
4

2 回答 2

1

尝试实现这个委托

- (void)previewController:(RPPreviewViewController *)previewController didFinishWithActivityTypes:(nonnull NSSet<NSString *> *)activityTypes {

    [previewController dismissViewControllerAnimated:YES completion:^{

    }];
}
于 2017-06-19T17:35:11.757 回答
1

在迅速 3.2

第一的:

class ViewController: UIViewController, RPPreviewViewControllerDelegate {

func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
        previewController.dismiss(animated: true, completion: nil)
    }
}

然后当停止录制按钮调用时,并将委托设置为关闭

if RPScreenRecorder.shared().isRecording {
RPScreenRecorder.shared().stopRecording { (previewController: RPPreviewViewController?, error: Error?) in
    if previewController != nil {
        let alertController = UIAlertController(title: "Recoring", message: "Do you wish to discard or view your recording?", preferredStyle: .alert)
        let discardAction = UIAlertAction(title: "Discard", style: .destructive, handler: nil)

        let viewAction = UIAlertAction(title: "View", style: .default, handler: { (action: UIAlertAction) in

            // set delegate here
            previewController?.previewControllerDelegate = self

            self.present(previewController!, animated: true, completion: nil)
        })

        alertController.addAction(discardAction)
        alertController.addAction(viewAction)
        self.present(alertController, animated: true, completion: nil)
    }
}

}

于 2017-06-11T03:04:36.973 回答