2016-07-07 1 views

답변

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") 

}