2012-01-25 7 views
0

アクションを含むUIAlertViewがポップアップするボタンが必要でした。ボタンをリンクしたUIAlertView代替ViewController

アラートがポップアップすると、1つのボタンがキャンセルされ、同じページに残り、1つのボタンが別のViewControllerにリンクする必要があります。

これは私がいくつかのフォーラムから集めたものですが、私は何をしているのか分からず、9つのエラーメッセージが表示されます。助けてください!

-(IBAction)Alert:(id)sender { 
    UIAlertView *Alert = [[UIAlertView alloc] initWithTitle:@"Alert" 
               message:@"Warning! By entering the Tutorial, all data will be lost. Are you sure you want to continue?" 
              delegate:self 
            cancelButtonTitle:@"Return to Data Collection" 
            otherButtonTitles:@"Continue", nil]; 
    [Alert Show]; 
    [Alert Release]; 
} 


- (void)Alert:(UIAlertView *)Alert clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if(Alert.tag==0) { 

     if(buttonIndex == 1)//OK button pressed 
     { 
      Tutorial *Info = [[Tutorial alloc] initWithNibName:nil bundle:nil]; 
      [self presentModalViewController:Info animated:YES]; 
     } 

コードの最初のボックスは、私は私のホーム画面上のボタンを押すと2つのボタンとアラートがポップアップするように動作します。

しかし、私は次のViewControllerにリンクするための2番目のボタンを取得できません。

答えて

3
  1. Objective-Cでは大文字と小文字が区別されます。

    [Alert show]; 
    [Alert release]; 
    

    - (void)alertView:(UIAlertView *)Alert clickedButtonAtIndex:(NSInteger)buttonIndex 
    

    (あなたがメソッドの名前を変更する場合はどのようにあなたは、それが動作することができ、思います???)

  2. あるのはなぜif(Alert.tag==0) {

  3. を削除あなたはここに雛ファイルの名前を渡さない:Tutorial *Info = [[Tutorial alloc] initWithNibName:nil bundle:nil];

  4. コーディング規則に従ってください。オブジェクトはcamelCaseで名前が付けられます。

結論を最初から学ぶためにあなたに良い本やビデオを取得します。そのためにはSome resources

+0

+1コーディング規則の場合 –

+0

nibNameにnilを渡すのは問題ありません。この場合は、名前がクラス名Tutorial.xibに一致するペン先をロードするだけです。もちろん、ペン先が呼び出されていない場合は問題があります。 –

関連する問題