gpt4 book ai didi

ios - 尝试在 上呈现 ,它已经在 swift 中呈现

转载 作者:行者123 更新时间:2023-11-30 13:41:41 25 4
gpt4 key购买 nike

好的,我正在添加一个请稍候弹出窗口,以便在我的 iOS 应用程序中执行比平时花费更长的时间的操作。

我有一个从 ViewController 到 TabController 的连接,当我像这样调用它时:

self.performSegueWithIdentifier("openMainApp", sender: self)

一切正常。

但是当我用以下内容包围它时:

let alert = UIAlertController(title: nil, message: "Please wait...", preferredStyle: .Alert)

alert.view.tintColor = UIColor.blackColor()
let loadingIndicator: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(10, 5, 50, 50)) as UIActivityIndicatorView
loadingIndicator.hidesWhenStopped = true
loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
loadingIndicator.startAnimating();

alert.view.addSubview(loadingIndicator)
presentViewController(alert, animated: true, completion: nil)

self.performSegueWithIdentifier("openMainApp", sender: self)

dismissViewControllerAnimated(false, completion: nil)

然后我收到警告:

Warning: Attempt to present <app.TabController: 0x7ff6dc00bd40>  
on <app.ViewController: 0x7ff6d9cf6600> which is already presenting
<UIAlertController: 0x7ff6d9d78530>

如何跳过此警告?

最佳答案

虽然此警告的来源对我来说仍然是个谜,但有一种方法可以跳过该警告。

  1. 从 Storyboard 中删除转场
  2. 将 Storyboard ID 提供给 View Controller ,例如:

    enter image description here

  3. 替换self.performSegueWithIdentifier(“openMainApp”,发件人:self)

    let viewController: UIViewController =
    self.storyboard!.instantiateViewControllerWithIdentifier("MainScene")
    self.presentViewController(viewController, animated: true, completion: nil)

关于ios - 尝试在 <app.ViewController> 上呈现 <app.TabController> ,它已经在 swift 中呈现 <UIAlertController>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35494781/

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