如何访问由ReplayKit框架的stopRecording()方法引发的视图控制器。以及如何在我的相机胶卷中保存视频

时间:2016-07-07 11:07:50

标签: ios swift replaykit

如何访问由ReplayKit框架的i = y * w + x方法引发的视图控制器。以及如何将视频保存在相机胶卷中?

1 个答案:

答案 0 :(得分:0)

如果你尚未开始工作,试试这个:

func stopRecording() {

let sharedRecorder = RPScreenRecorder.sharedRecorder()

sharedRecorder.stopRecordingWithHandler { (previewViewController: RPPreviewViewController?, error: NSError?) in

if previewViewController != nil {

            print("stopped recording")

            previewViewController!.previewControllerDelegate = self

            let alertController = UIAlertController(title: "Recording", message: "Tap view to watch, edit, share, or save your screen recording!", preferredStyle: .Alert)

            let viewAction = UIAlertAction(title: "View", style: .Default, handler: { (action: UIAlertAction) -> Void in
            self.view?.window?.rootViewController?.presentViewController(previewViewController!, animated: true, completion: nil)
})
            alertController.addAction(viewAction)

            self.previewViewController = previewViewController!
            self.previewViewController.modalPresentationStyle = UIModalPresentationStyle.FullScreen
            self.view?.window?.rootViewController!.presentViewController(alertController, animated: true, completion: nil)


} else {
    print("recording stopped working")

//create the alert

    let alert = UIAlertController(title: "Alert", message: "Sorry, there was an error recording your screen. Please Try Again!", preferredStyle: UIAlertControllerStyle.Alert)

    // show the alert
    self.view!.window?.rootViewController!.presentViewController(alert, animated: true, completion: nil)

    alert.addAction(UIAlertAction(title: "Try Again!", style: UIAlertActionStyle.Destructive, handler: { action in
    // add action

        }))
     }
   }
}


internal func previewControllerDidFinish(previewController: RPPreviewViewController) {

self.previewViewController.dismissViewControllerAnimated(true, completion: nil)


print("cancel and save button pressed")

}