我想显示工作表,当用户单击“确定”时,显示另一张工作表。依次显示NSAlert工作表模式
然而,点击“确定”的时刻整个设计变得混乱,好像第一张警报表没有足够的时间消失。
这是我使用的床单代码:
#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]);
}
}
任何想法?我究竟做错了什么?
很好的答案。有用。非常感谢! :-) – 2012-04-06 03:33:24