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];
4

1 回答 1

0

有什么NSThread不能使用的原因吗?这是显而易见的答案...

于 2012-02-13T06:46:43.623 回答