2016-04-11 9 views
2

私はその理由を理解していません。私のアプリでリプレイキットを使用して、私はその画面を記録した後にポップアップするUIを解除しようとしています。左上にキャンセルボタンがあり、プレビューコントローラーを押してもキャンセルされません。コントローラーを却下するデリゲート機能はありますが、それは私のためには機能しません。私はこれが簡単な修正だと思っていますが、私は何が間違っているのか分かりません。私を助けてください。もっと情報が必要なら私に知らせてください。ありがとうございました!SwiftでプレビューUIコントローラを非表示にするにはどうすればよいですか?

func startRecoding() { 


if RPScreenRecorder.sharedRecorder().available { 
    RPScreenRecorder.sharedRecorder().startRecordingWithMicrophoneEnabled(true, handler: { (error: NSError?) -> Void in 
     if error == nil { // Recording has started 

     } else { 
      // Handle error 
     } 
    }) 
} else { 
    // Display UI for recording being unavailable 

} 


} 

func stopRecording() { 

RPScreenRecorder.sharedRecorder().stopRecordingWithHandler { (previewController: RPPreviewViewController?, error: NSError?) -> Void in 

    if previewController != nil { 

     let alertController = UIAlertController(title: "Recording", message: "Do you wish to discard or view your gameplay recording?", preferredStyle: .Alert) 

     let discardAction = UIAlertAction(title: "Discard", style: .Default) { (action: UIAlertAction) in 
      RPScreenRecorder.sharedRecorder().discardRecordingWithHandler({() -> Void in 
       // Executed once recording has successfully been discarded 
      }) 
     } 

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



     }) 

     alertController.addAction(discardAction) 
     alertController.addAction(viewAction) 

     self.view?.window?.rootViewController!.presentViewController(alertController, animated: true, completion: nil) 

    } else { 
     // Handle error 
    } 
    } 



    } 


func previewControllerDidFinish(previewController: RPPreviewViewController) { 
    previewController.dismissViewControllerAnimated(true, completion: nil) 

} 
+0

現在解雇しようとしているビューを表示するために使用しているコードを表示してください。 –

+0

大丈夫です。 – coding22

+0

今すぐ確認できるコードを更新しました。 – coding22

答えて

1

プレビュービューコントローラのデリゲートを設定する必要があります。

+0

それでは、私はpreviewControllerDidFinishの中に何を入れますか? – coding22

+1

できます。または、ボタンによってトリガーされるメソッドを使用して閉じることもできます。 –

+0

はい、今動作します。ありがとうございました! – coding22

関連する問題