如何摆脱关于视图相互叠加的通知?
How do I get rid of the notification about view presenting on top of each other?
我有一个对另一个视图执行 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;
}
您不能在 prepareForSegue
中显示视图控制器(例如 UIAlertController
)。那时 segue 已提交,您无法更改视图表示。
为了执行验证,显示警报并可能取消您应该实施的导航 shouldPerformSegueWithIdentifier
我有一个对另一个视图执行 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;
}
您不能在 prepareForSegue
中显示视图控制器(例如 UIAlertController
)。那时 segue 已提交,您无法更改视图表示。
为了执行验证,显示警报并可能取消您应该实施的导航 shouldPerformSegueWithIdentifier