这是我的代码:
let library = ALAssetsLibrary()
library.writeVideoAtPathToSavedPhotosAlbum(NSURL(string: path), completionBlock: { (url, error) -> Void in
if error != nil {
let error = UIAlertController(title: "Error!", message:
"Your video is NOT saved!", preferredStyle: UIAlertControllerStyle.Alert)
error.addAction(UIAlertAction(title: "Shit!", style: UIAlertActionStyle.Default,handler:
{ action in navigationController!.popViewControllerAnimated(true) }))
self.presentViewController(error, animated: true, completion: nil)
} else {
let alertController = UIAlertController(title: "Done!", message:
"Your video is saved!", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Nice!", style: UIAlertActionStyle.Default,handler:
{ action in navigationController!.popViewControllerAnimated(true) }))
self.presentViewController(alertController, animated: true, completion: nil)
}
})
如果我按下" OK"那么说保存视频的AlertController会出现两次。真的很快(如果我等了几秒钟,一切都很好)。问题是什么,我该如何解决?