【发布时间】:2012-04-19 06:44:52
【问题描述】:
我想显示一个工作表,当用户单击“确定”时,显示另一个工作表。
然而,点击“OK”的那一刻,整个设计就变得一团糟,好像第一个警告表还没有足够的时间消失。
这是我用于工作表的代码:
#define CONFIRM_ALERT(X,Y,Z,W,V) \
NSAlert* confirmAlert = [NSAlert alertWithMessageText:X \
defaultButton:@"OK" \
alternateButton:@"Cancel" \
otherButton:nil \
informativeTextWithFormat:Y]; \
[confirmAlert beginSheetModalForWindow:Z \
modalDelegate:self \
didEndSelector:W \
contextInfo:V];
#define INFO_ALERT(X,Y,Z) \
NSAlert *infoAlert = [[NSAlert alloc] init]; \
[infoAlert addButtonWithTitle:@"OK"]; \
[infoAlert setMessageText:X]; \
[infoAlert setInformativeText:Y];\
[infoAlert setAlertStyle:NSInformationalAlertStyle]; \
[infoAlert beginSheetModalForWindow:Z modalDelegate:self didEndSelector:nil contextInfo:nil];
以及我是如何使用它的:
- (void)doSth
{
CONFIRM_ALERT(@"New Action",
@"Are you sure you want to proceed?",
[self window],
@selector(confirm:code:context:),
nil);
}
- (void)confirm:(NSAlert*)alert code:(int)choice context:(void *)filename
{
if (choice == NSAlertDefaultReturn)
{
INFO_ALERT(@"Success :-)",
@"The Action has been successfully completed.",
[self window]);
}
}
有什么想法吗?我做错了什么?
【问题讨论】:
标签: objective-c cocoa modal-dialog nsalert