Ios 线程8:执行segue时发出信号SIGABRT
这发生在我保存视频时,我还试图切换到另一个视图控制器。我不知道为什么应用程序会在这里崩溃Ios 线程8:执行segue时发出信号SIGABRT,ios,swift,xcode,Ios,Swift,Xcode,这发生在我保存视频时,我还试图切换到另一个视图控制器。我不知道为什么应用程序会在这里崩溃 func finalExportCompletion(_ session: AVAssetExportSession) { PhotoManager().saveVideoToUserLibrary(fileUrl: session.outputURL!) { (success, error) in if success { ProgressHUD.showS
func finalExportCompletion(_ session: AVAssetExportSession) {
PhotoManager().saveVideoToUserLibrary(fileUrl: session.outputURL!) { (success, error) in
if success {
ProgressHUD.showSuccess("Video Saved", interaction: true)
self.finalVideo = session.outputURL!
//FileManager.default.clearTmpDirectory()
self.clipsCollectionView.reloadData()
} else {
ProgressHUD.show(error?.localizedDescription)
}
self.performSegue(withIdentifier: "toPostVideoViewController", sender: nil)
}
}
当你在后台线程时,你的崩溃被发布到UI中的修改中,正如你的崩溃日志所说,@rmaddy在他的评论中说,
线程8
是后台线程,你需要在线程1
中执行你的所有UI操作,这是“主线程”,你必须这样修改你的代码
func finalExportCompletion(_ session: AVAssetExportSession) {
PhotoManager().saveVideoToUserLibrary(fileUrl: session.outputURL!) { (success, error) in
DispatchQueue.main.async{
if success {
ProgressHUD.showSuccess("Video Saved", interaction: true)
self.finalVideo = session.outputURL!
//FileManager.default.clearTmpDirectory()
self.clipsCollectionView.reloadData()
} else {
ProgressHUD.show(error?.localizedDescription)
}
//I don't know if you anyway want to go to "toPostVideoViewController" this you need to do it also in main thread
self.performSegue(withIdentifier: "toPostVideoViewController", sender: nil)
}
}
}
session.outputURL!,在我看来,这是罪魁祸首。将其设置为可选并安全地展开。显示右上角的“实用程序”面板转到“连接检查器”,并确保已删除从视图或到视图的所有额外连接!不要在后台线程上执行UI更新。我尝试使用if let video=session.outputURL安全地展开它!{这给了我一个错误:条件绑定的初始值设定项必须具有可选类型,而不是'URL'@rmaddy。你是什么意思?这是否意味着我不应该在那里执行segue?在
saveVideoToUserLibrary
回调闭包中使用一个DispatchQueue.main.async
会简单得多,因为其中的所有内容都需要排队吧。谢谢你们。谢谢你们的帮助!