2012-04-05 6 views
1

시트를 표시하고 사용자가 "확인"을 클릭하면 다른 시트를 표시합니다.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 또는 이와 동등한 방법을 사용하여 다음 실행 루프에서 시트를 지연시켜 표시해야합니다.