[問題] 錄影儲存出現的alertView

看板MacDev作者 (JJ)時間12年前 (2012/11/23 11:40), 編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/1
在錄影停止時會出現影片儲存的alertView 在viewDidLoad 已經先 [captureSession startRunning]; 錄影按鈕 與錄影結束按鈕相同 - (IBAction)record:(id)sender { if (!isRecord) { ... [captureOutput startRecordingToOutputFileURL:theFileURL recordingDelegate:self]; isRecord = Yes; } else{ [NSThread detachNewThreadSelector: @selector(actIndicatorBegin) toTarget:self withObject:nil]; [captureSession stopRunning]; [captureOutput stopRecording]; [captureSession startRunning]; [NSThread detachNewThreadSelector: @selector(actIndicatorEnd) toTarget:self withObject:nil]; isRecord = NO; } } //由執行緒產生alertView - (void) actIndicatorBegin { //建立警示視圖 alertView = [[UIAlertView alloc]initWithTitle:@"影片儲存中" message:@"" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil]; [alertView show]; //建立活動指示器,並啓動旋轉動畫 indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; indicator.center = CGPointMake(CGRectGetMidX(alertView.bounds) , CGRectGetMidY(alertView.bounds)); [indicator startAnimating]; //加入警示視圖 [alertView addSubview:indicator]; } //結束alertView - (void) actIndicatorEnd { //解除警示視圖 重置靜態變數 [alertView dismissWithClickedButtonIndex:0 animated:YES]; [indicator removeFromSuperview]; indicator = nil; alertView = NULL; } 現在問題來了 第ㄧ次點擊停止錄影時 畫面會先暫停 才出現警示試圖 第二次點擊停止錄影時 會先出先警示視圖 畫面才暫停 (正常) 第三第四次....都是正常 雖然編譯不會錯 但是第ㄧ次的停止怪怪的 所以感覺我這樣的寫法是錯的... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.40.175.94

11/23 12:10, , 1F
detachNewThreadSelector: 本來就不保證 selector 裡面
11/23 12:10, 1F

11/23 12:10, , 2F
的事情會比 detachNewThreadSelector: 後面的事情先發生
11/23 12:10, 2F
所以在這個部分能給點提示嗎>< 還是沒有頭緒... ※ 編輯: j5307 來自: 114.40.167.162 (11/25 11:45) 找到方法了 感恩 ※ 編輯: j5307 來自: 114.40.167.162 (11/25 13:16)
文章代碼(AID): #1Ghl1BBz (MacDev)
文章代碼(AID): #1Ghl1BBz (MacDev)