gpt4 book ai didi

ios - 如何摆脱有关 View 相互叠加的通知?

转载 作者:行者123 更新时间:2023-11-29 00:24:34 25 4
gpt4 key购买 nike

我有一个按钮可以执行 Segue 到另一个 View ,因此没有代码或操作连接到按钮,它全部使用 Storyboard完成,但在 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 中呈现 View Controller (例如 UIAlertController)。此时,segue 已提交,您无法更改 View 呈现。

为了执行验证、显示警报并可能取消导航,您应该实现 shouldPerformSegueWithIdentifier

关于ios - 如何摆脱有关 View 相互叠加的通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43434596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com