如何使我的程序等待NSOpenPanel关闭? [英] How do I make my program wait for NSOpenPanel to close?

查看:119
本文介绍了如何使我的程序等待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关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆