2017-04-16 2 views
0

私はSegueを別のビューに表示するボタンを持っているので、ボタンに接続されているコードやアクションはありません。すべてストーリーボードを使用して行われますが、prepareForSegueです。どのようにして、それぞれの上に表示されるビューに関する通知を取り除くことができますか?

は、私は特定の値がNULLである場合にはチェックを追加した、とチェックが期待通りに動作しますが、私は一般的には、実行時の警告やコンパイラの警告を好きではない

2017-04-16 14:50:03.653 NWMobileTill[34117:830763] Warning: Attempt to present <TenderListView: 0x7ff81870b280> on <TransactionListView: 0x7ff818738530> which is already presenting <UIAlertController: 0x7ff81864fff0> 

実行時にこの警告を得ますかだから、この警告を取り除くために何をする必要があるのですか?ボタンをクリックしたときに私のチェックを続けてください。

これはprepareForSegueあなたはprepareForSegueに(例えばUIAlertControllerなど)ビュー・コントローラを提供することができない

+0

何をしますか実装する必要があり、ナビゲーションをキャンセルするために? 'prepareForSegue'を表示できますか? – Paulw11

+0

コードのスニペットを編集して追加しましたが、警告が出る場合でも正常に動作します –

答えて

1
if ([[segue identifier] isEqualToString:@"trListViewToTenderList"]) { 
    if([NWTillHelper getCurrentOrderNumber] == nil) { 
     //Step 1: Create a UIAlertController 
     UIAlertController *userInfoCheck = [UIAlertController alertControllerWithTitle:@"Tender" 
                       message: @"No active transaction, you need to have an active transaction before you can add tenders!" 
                     preferredStyle:UIAlertControllerStyleAlert]; 

     //Step 2: Create a UIAlertAction that can be added to the alert 
     UIAlertAction* ok = [UIAlertAction 
          actionWithTitle:@"OK" 
          style:UIAlertActionStyleDefault 
          handler:^(UIAlertAction * action) 
          { 
           [userInfoCheck dismissViewControllerAnimated:YES completion:nil]; 

          }]; 

     //Step 3: Add the UIAlertAction ok that we just created to our AlertController 
     [userInfoCheck addAction: ok]; 

     //Step 4: Present the alert to the user 
     [self presentViewController:userInfoCheck animated:YES completion:nil]; 
     return; 
    } 

    TenderListView *destViewController = segue.destinationViewController; 
    destViewController.tenderListViewAmountToPayStr = _transactionListViewUberTotalSumLbl.text; 
} 

をスニペットです。その時点で、セグがコミットされ、ビューの表示を変更することはできません。

、検証を行い、警告を表示し、潜在的にあなたは値がnullのときにshouldPerformSegueWithIdentifier

+0

これは以前に呼び出されているので、NOまたはYESを返すことができますが、入力としてセグを取ることはできません。私が提供する必要がある識別子これを使用するときにどのセグが起こっているかを知る方法について少し混乱していますか? –

+0

ストーリーボードのセグを選択して、識別子を割り当てることができます。 – Paulw11

+0

ええ、([identifier isEqualToString:@ "trListViewToTenderList"])がトリックをした場合、私はちょっと名前をつけてちょっと混乱させました。 –

関連する問題