我想显示一个工作表,当用户单击“确定”时,显示另一个工作表。
然而,点击“确定”的那一刻,整个设计就变得一团糟,就好像第一个警报表还没有足够的时间消失一样。
这是我用于工作表的代码:
#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]);
}
}
有任何想法吗?我究竟做错了什么?