シートを表示したい場合は「OK」をクリックして別のシートを表示します。NSAlertシートモーダルを次々に表示
しかし、「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]);
}
}
任意のアイデア?私は間違って何をしていますか?
偉大な答え。できます。どうもありがとう! :-) –