2010-07-02 4 views
-3

내 앱에 경고 메시지가 필요하고 예 버튼을 클릭하면 마지막 작업을 결정하는 다른 경고 메시지를 클릭합니다. - (void) alertView : (UIAlertView *) alertView didDismissWithButtonIndex : (NSInteger) buttonIndex 이 메서드는 사용하고 있습니다.UIAlert보기 용 예/아니오 조건

도와주세요.

+1

도움이 어떤 종류의 할 ? –

+0

Thaks Marcelo Cantos.I 두 개의 경고 메시지가 필요하지만 첫 번째 메시지가 예이면 2 번째 메시지이고 두 번째 메시지가 예인 경우 메서드 호출을 원합니다. alert.tag == 1을 사용했지만 작동하지 않습니다. 내 코드를 볼 수 있습니다. 포럼에 게시되었습니다. 도와 주시면 도와 드리겠습니다. 감사합니다. – 1988

답변

0

확인이 밖으로 http://www.timeister.com/2010/06/objc-show-alert-iphone/

// open a alert with an OK and cancel button 
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView" 
     message:@"My message" delegate:self cancelButtonTitle:@"Cancel" 
     otherButtonTitles:@"OK", nil]; 
[alert show]; 
[alert release]; 
+0

Adrian.I 감사합니다. 사용했으나 다른 경고 메시지를 원합니다. 그래도 괜찮 으면 내 작업을 수행해야합니다. 도와주세요. – 1988

+0

* Ok delegate * result를 수신 한 다음 새 경고를 표시하면됩니다. :) –

+0

감사합니다 애드리안 Pirvulescu,하지만 어떻게 Ok 대표자의 결과를 듣고? 코드를 도와주세요. 감사합니다. – 1988

1

수행 경고를 표시하기 전에 - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex가 호출 alert.tag = 1; 다음합니까 무엇 @Adrian Pirvulescu가 말했지만 : 당신이 필요로하는

if (alertView.tag == 1) { 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"2nd Alert" 
    message:@"My message" delegate:self cancelButtonTitle:@"Cancel" 
    otherButtonTitles:@"OK", nil]; 
    alert.tag = 2; 
    [alert show]; 
    [alert release]; 
} 
else if (alertView.tag == 2) { 
    [self CallSomeMethod]; 
} 
else { 
    //do what ever you want here 
} 
+0

고마워요, 작동 중입니다.하지만 alert.tag = 2 일 때 나는 메소드를 호출하고 싶습니다. if 메소드 내부 또는 if can not 내부에서 호출하기 때문에 어디에서 호출해야합니까? 제발 도와주세요. 감사합니다. – 1988

+0

내 대답이 업데이트되어이를 수행하는 방법을 알려줍니다. – jamone

+0

Jamone.But alertView.tag == 1이 작동하지 않습니다. & 0을 입력하면 두 버튼 모두에서 작동합니다. 포럼에 내 코드를 게시하면 참조하십시오. 감사합니다. . – 1988