取自本网站: http: //www.mactech.com/articles/mactech/Vol.21/21.08/Threads/index.html
如果影片非常大,此方法可能需要很长时间才能完成。在此期间,用户将无法对应用程序执行任何操作,只能移动窗口。不是很令人兴奋。
稍微好一点的解决方案是使用 movie:shouldContinueOperation:withPhase:atPercent:withAttributes: 委托方法。这是围绕 QuickTime 的电影进度功能的包装,将用于显示一个对话框,显示导出进度并允许用户取消操作。这里试试这个
- (BOOL)movie:(QTMovie *)movie
shouldContinueOperation:(NSString *)op
withPhase:(QTMovieOperationPhase)phase
atPercent:(NSNumber *)percent
withAttributes:(NSDictionary *)attributes
{
OSErr err = noErr;
NSEvent *event;
double percentDone = [percent doubleValue] * 100.0;
switch (phase) {
case QTMovieOperationBeginPhase:
// set up the progress panel
[progressText setStringValue:op];
[progressBar setDoubleValue:0];
// show the progress sheet
[NSApp beginSheet:progressPanel
modalForWindow:[movieView window] modalDelegate:nil
didEndSelector:nil contextInfo:nil];
break;
case QTMovieOperationUpdatePercentPhase:
// update the percent done
[progressBar setDoubleValue:percentDone];
[progressBar display];
break;
case QTMovieOperationEndPhase:
[NSApp endSheet:progressPanel];
[progressPanel close];
break;
}
// cancel (if requested)
event = [progressPanel
nextEventMatchingMask:NSLeftMouseUpMask
untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode dequeue:YES];
if (event && NSPointInRect([event locationInWindow],
[cancelButton frame])) {
[cancelButton performClick:self];
err = userCanceledErr;
}
return (err == noErr);
}
希望这可以帮助。
如果您需要任何帮助,请告诉我。如果这对 lil 有帮助,请告诉我。
PK