【发布时间】:2011-11-10 18:42:43
【问题描述】:
我目前正在通过实现我认为 Titanium Appcelerator Desktop SDK 中缺少的功能来学习(通过做)objective-c:一种使用自定义按钮文本进行模态对话框并可选择将它们显示为“工作表”的方法.
一切都很好,但是,当将 NSAlert 显示为“工作表”时,我创建警报的方法会立即返回,这就是我想要阻止的。
创建警报的方法返回一个 int(来自 NSAlert 的返回码)。
里面的代码基本上归结为:
int returnCode = -1;
if (displayAsSheet) {
[alert beginSheetModalForWindow:nativeWindow modalDelegate:delegate didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil];
} else {
returnCode = [alert runModal];
}
return returnCode;
modalDelegate 是一个实现所需的对象:
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
现在它只是对 returnCode 进行 NSLog。
所以我的问题是:
如何阻止我的方法返回,直到“工作表”被解除?
或者我是不是走错了路?
【问题讨论】:
标签: objective-c titanium desktop appcelerator nsalert