我有一个按钮,可以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片段
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;
}
答案 0 :(得分:1)
您无法在UIAlertController
中展示视图控制器(例如prepareForSegue
)。此时,segue已提交,您无法更改视图演示。
要执行验证,请显示提醒并可能取消您应实施的导航shouldPerformSegueWithIdentifier