2010-08-16 3 views
3

나는 2 UIAlert가 표시됩니다. 나는 버튼을 누릅니다. 첫 번째 확인 단추를 눌렀을 때 첫 번째 UIAlert가 해제 될 때만 두 번째 경고가 표시되도록하고 싶습니다.2 UIAlertView 다른 하나 다음에

어떻게 진행해야합니까? 아래 코드는

- (IBAction)button:(id)sender { 
UIAlertView *view; 
view = [[UIAlertView alloc] 
    initWithTitle: @"Message" 
    message: @"Adding..." 
    delegate: self 
    cancelButtonTitle: @"OK" otherButtonTitles: nil]; 
[view show]; 

MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate]; 

if (appDelegate.array_presets.count) { 
    view = [[UIAlertView alloc] 
    initWithTitle: @"Message" 
    message: @"limit already reached" 
    delegate: self 
    cancelButtonTitle: @"OK" otherButtonTitles: nil]; 
    [view show]; 
} 

[view autorelease]; 
} 

답변

5

두 개의 경고보기에 서로 다른 태그를 사용하십시오.

alertView.tag = 1000; 

경고보기 대리자 메서드를 구현하고 태그 값을 확인하십시오. 대리자가 첫 번째 경고보기로 호출되면 두 번째 경고보기가 만들어지고 표시됩니다.

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 
    if(alertView.tag == 1000) 
    { 
     //first alert view's button clicked 
     UIAlertView *view = [[UIAlertView alloc] 
       initWithTitle: @"Message" 
       message: @"limit already reached" 
       delegate: self 
       cancelButtonTitle: @"OK" otherButtonTitles: nil]; 
     view.tag = 2000; 
     [view show]; 
    } 
    if(alertView.tag == 2000) 
    { 
     //handle second alert view's button action 
    } 

} 
+0

당신은 아마 "경우"경우 (alertView.tag! = 1000) '두 번째에'사용하거나 (1001) 같은 다른 값을 확인하는 것을 의미하지만 내 생각은, 포스터의 문제가 해결되지 않습니다 . – DarkDust

+0

고마워. 답변에서 코드를 편집했습니다. 첫 번째 경보가 해제 된 후 두 번째 경고보기를 표시하려고 할 때 문제가 해결되어야한다고 생각합니다. – lukya