loadFile
方法启动NSTimer
以随时间加载进程文件,而不会在while循环中阻止应用程序。该定时器不会使用第一位代码触发,而是使用第二位。问题是第二位将工作表显示为面板样式窗口,而不是工作表。
如何获得仍可以使用的工作表?
显示工作表但没有完成工作
[self.sheetView loadFile:filename];
[[NSApplication sharedApplication] beginSheet: self.sheetView
modalForWindow: self.window
modalDelegate: self
didEndSelector: nil
contextInfo: nil];
[[NSApplication sharedApplication] runModalForWindow: self.sheetView];
显示窗口并完成工作
NSModalSession session = [NSApp beginModalSessionForWindow:self.sheetView];
NSInteger result = NSRunContinuesResponse;
[self.sheetView loadFile:filename];
// Loop until some result other than continues:
while (result == NSRunContinuesResponse)
{
// Run the window modally until there are no events to process:
result = [NSApp runModalSession:session];
// Give the main loop some time:
[[NSRunLoop currentRunLoop] limitDateForMode:NSDefaultRunLoopMode];
}
[NSApp endModalSession:session];
答案 0 :(得分:0)
是否有理由不能使用NSThread
?这是明显的答案......