[英]AVExportSession change view on completion
我在使用AVExportSession時遇到了許多相關問題。 我非常清楚自己可能會嘗試這種錯誤,但是嘗試了幾種解決方案,但均無濟於事。
我正在使用AVExportSession導出合成,然后使用完成處理程序在完成后觸發其他代碼(通常應在3秒鍾之內)。 當我想在完成時更改視圖時,問題就來了。 例如,我在模式視圖中有一個按鈕可以觸發音頻導出,但是我希望它隨后在完成時關閉視圖。 我收到的錯誤消息非常明顯-“這可能是從輔助線程調用UIKit的結果。”
NSURL *exportURL = [NSURL fileURLWithPath:saveSong];
exportSession.outputURL = exportURL;
exportSession.outputFileType = @"com.apple.m4a-audio";
[exportSession exportAsynchronouslyWithCompletionHandler:^{
if (AVAssetExportSessionStatusCompleted == exportSession.status) {
NSLog(@"AVAssetExportSessionStatusCompleted");
[[NSNotificationCenter defaultCenter]
postNotificationName:@"end"
object:self];
} else if (AVAssetExportSessionStatusFailed == exportSession.status) {
// a failure may happen because of an event out of your control
// for example, an interruption like a phone call comming in
// make sure and handle this case appropriately
NSLog(@"AVAssetExportSessionStatusFailed");
} else {
NSLog(@"Export Session Status: %d", exportSession.status);
}
}];
我當前的嘗試涉及發送NSNotification來關閉視圖,以嘗試跳到主線程上。
非常抱歉,如果這看起來不清楚-我在尋找解決方案時遇到的部分問題是表達了出了什么問題。 我希望通過將我摸索的描述發布出去,以使某人可能有正確的問題要問我,從而找到答案的線索!
這也是我要解決的另一個問題的分支。 開始導出時,我會取消隱藏動畫的UIActivityView,但是當嘗試在完成時隱藏時,UIActivityView最終會在完成后約20秒(NSLog-ed)隱藏
解決方案:使用[self performSelectorOnMainThread:@selector(stopActivityIndicator)withObject:nil waitUntilDone:YES];
然后從-(void)stopActivityIndicator調用我的視圖更改/活動指示符
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.