本文介绍了如何使我的程序等待NSOpenPanel关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像标题中所述,我需要让程序等待,直到我的NSOpenPanel关闭.我在windowControllerWillLoadNib中打开了面板,以便它在我的文档窗口打开之前发生.但是发生的是,它只加载了两个窗口,而没有等待面板关闭.我如何才能等到打开的面板关闭并完全完成?

Like the title states, I need to make my program wait until my NSOpenPanel closes. I have the panel open in windowControllerWillLoadNib so that it happens before my document window opens. But what happens is that, it just loads both windows without waiting for the panel to close. How can I make it wait until the open panel is closed and completely finished?

推荐答案

使用runModal方法.

use runModal method.

代码示例:

int result;
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
result = [oPanel runModalForDirectory:NSHomeDirectory() file:nil types:nil];
if (result == NSOKButton) {
//your code
}

这篇关于如何使我的程序等待NSOpenPanel关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 01:54