2012-05-03 24 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としてゼロとnilを渡すを示していない、あなたは、少なくとも1つのボタンのタイトルが設定されている必要があります。

関連する問題