2012-05-03 4 views
1

안녕 얘들 아 내가 버튼에 연결 IBAction를 : SecondViewControllerclickedButtonAtIndex :이이 작동하지

- (IBAction)showCurl:(id)sender { 
     alert1 = [[UIAlertView alloc]initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; 
     [alert1 show]; 

}

및 자동 실행에 clickedButtonIndex하지만 어떻게 든로드되지 않습니다

#pragma mark UIAlertView 
- (void)alertView:(UIAlertView *)alert1 clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if(buttonIndex == 0){ 
     SecondViewController *sampleView = [[SecondController alloc] init]; 
     [sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl]; 
     [self presentModalViewController:sampleView animated:YES]; 
     } 
    else{ 
      // Cancel prompt 
     } 
} 

여기에 뭔가가 있습니까?

+0

무엇이 문제입니까? 경고가 표시 되었습니까? 그렇다면 위임 메서드가 호출 되었습니까? –

+0

경고가 표시되지만'- (void) alertView : (UIAlertView *) alert1 clickedButtonAtIndex : (NSInteger) buttonIndex {' –

답변

2

경고에 일부 단추 제목을 표시하지 않으면 누르는 단추가 없으며 해당 대리자 메서드가 호출되지 않습니다.

- (IBAction)showCurl:(id)sender { 
     alert1 = [[UIAlertView alloc] initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
     [alert1 show]; 
} 
+0

에 반영된대로 SecondViewController로 전환하지 않습니다. 그러면 사용자가 버튼을 클릭하면 어떻게됩니까? 로드가 발생하면 경고가 표시되고 데이터가로드되면 경고가 표시됩니까? –

+1

데이터를 어떻게로드하는지에 따라 다르지만'-didFinishLoading' 델리게이트 콜백 또는 다른 알림에 대한 응답으로 뷰를 시작하거나 닫을 때 뷰를 제공합니다. UIAlertView는 또한 이것을 위해 잘못된 UI 구성 요소입니다. 사용자에게 선택지를 제시하기 위해 절대로 사용해야합니다. 일반적으로, 특히 iOS에서 항목을로드 할 때 모달보기를 사용하여 기본 UI를 차단하지 않아야합니다. –

0

귀하의 코드는 버튼

alert1 = [[UIAlertView alloc]initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:**nil** otherButtonTitles:**nil**]; 

당신은 otherbuttonTitles로 cancelButtonTitle로 전무와 전무를 통과 표시되지 않습니다, 당신은 적어도 하나 개의 버튼 타이틀 세트가 있어야합니다.