0
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];
其由NSTimer定时在面板上的自定义视图中正确显示动画。我想我也可以在NSThread中做到这一点,但是如果我不必这样做,我不想再多花一分钱(并且在学习过程中学习NSThread)。 – Justin808 2012-02-13 06:51:49