2012-04-05 3 views
1

シートを表示したい場合は「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]); 
    } 
} 

任意のアイデア?私は間違って何をしていますか?

答えて

2

performSelector:withObject:afterDelayまたはこれと同等の方法を使用して次の実行ループにシートを表示する必要があります。

関連する問題