2015-01-06 5 views
1

나는 2 개의 UIAlertview를 가지고 있는데, 나는 다른 페이지로 가야한다. 두 개의 xib 파일을 만들고 주된 ViewController에서 가져 오지만, 왜 보이지 않는지는 모른다. 잘못된 플래그 내가 확인할 때 ~ 여기 내 코드입니다 :두 UIAlertView

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"LP01;" message:@"No Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Help", nil]; 


UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"LP01;" message:@"No Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Help", nil]; 




- (void)alert:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex { 


      if (buttonIndex == 1) { 

     AViewController *switch1 = [[AViewController alloc] 
            initWithNibName:nil bundle:nil]; 
     [self presentViewController:switch1 animated:YES completion:NULL]; 

      } 
} 

- (void)alert1:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex { 



    if (buttonIndex == 1) { 


     BViewController *switch2 = [[BViewController alloc] 
            initWithNibName:nil bundle:nil]; 
     [self presentViewController:switch2 animated:YES completion:NULL]; 

    } 
} 

이 제발 도와주세요 감사 ~

+0

이 질문이 지금 해결 되었습니까 ?? –

+0

아직 해결되지 않았습니다 ~ –

답변

0
UIAlertView *firstAlert = [[UIAlertView alloc] initWithTitle:@"LP01;" message:@"No Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Help", nil]; 


UIAlertView *secondAlert = [[UIAlertView alloc] initWithTitle:@"LP01;" message:@"No Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Help", nil]; 

// 여기에 관련 요소의 수에 대해 동일합니다 위임 방법을 기억하십시오. 그래서 당신이 2 또는 3 또는 5 UIAlertView의 여부를 위임하는 메서드는 한 번만 작성됩니다.

- (void)alert:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if(alertview == firstAlert){ 



      AViewController *switch1 = [[AViewController alloc] 
             initWithNibName:nil bundle:nil]; 
      [self presentViewController:switch1 animated:YES completion:NULL]; 


    } 
    else if(alertview == secondAlert){ 



      BViewController *switch2 = [[BViewController alloc] 
             initWithNibName:nil bundle:nil]; 
      [self presentViewController:switch2 animated:YES completion:NULL]; 


    } 
} 

// [firstAlert show]를 잊지 마세요. 또는 [secondAlert show]; 알림을 표시하려면

+0

덕분에, 내 문제를 해결 ~ –