【问题标题】:UIAlertView warning when dismissing关闭时的 UIAlertView 警告
【发布时间】:2014-09-05 00:36:12
【问题描述】:

我正在通过以下方式创建警报:

let alert = UIAlertView(title: "Network Unavailable",
                      message: "Oh noes!",
                     delegate: nil,
            cancelButtonTitle: "OK")
alert.show()

工作正常。但是,当我单击“确定”按钮关闭警报时,我得到了这个:

警告:在演示或关闭过程中尝试从视图控制器 <_uialertshimpresentingviewcontroller:> 关闭!

一些上下文:

  1. 警报是在 SKScene 的 didMoveToView(view: SKView!) 函数中创建的。
  2. 这是在 Xcode 6 beta 3 中。
  3. 我的例子很快,但这也发生在 Objective-C 中

知道为什么会出现此警告吗?我不想忽略它,以防它在未来的 iOS 版本中变成致命错误。

更新

我还应该补充一点,当警报出现时,当我选择 Debug -> View Debugging -> Capture View Hierarchy 时,警报不会显示在视图的 3d 视图中。我想知道这是否是我做错了什么的征兆。

【问题讨论】:

  • 为什么在 Swift 中显然?!我个人认为 Swift 是我读过的最令人困惑、最烦人、设计最糟糕的语言之一......不过,我有同样的问题,并且认为这仍然可能是一个错误!请注意,我们仍处于测试阶段!
  • @Julian - “显然在 swift 中”因为代码示例是 swift 而不是因为该错误仅在 Swift 中出现。 OP 显然担心它是一个快速的错误。
  • 你尝试过这些解决方案吗:stackoverflow.com/questions/14907518/…
  • 我遇到了同样的问题。不使用 spritekit 或 Swift (100% objective-c)。点击取消会导致错误,并使下一个操作表加载非常缓慢。
  • 另外,我一直在尝试调试它,我注意到没有调用 didPresentActionSheet。这与技术上“不显示”是一致的。

标签: warnings sprite-kit uialertview dismiss skscene


【解决方案1】:

我收到了同样的警告:

警告:在演示或关闭过程中尝试从视图控制器 <_uialertshimpresentingviewcontroller:> 关闭!

在 iOS8 中,UIAlertController 取代了 UIAlertView。这应该可以解决您的警告(在 Objc 中):

UIAlertController *alert =
  [UIAlertController alertControllerWithTitle:@"Network Unavailable"
                                      message:@"Oh noes!"
                               preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *cancelAction =
  [UIAlertAction actionWithTitle:@"Ok"   
                           style:UIAlertActionStyleCancel
                         handler:^(UIAlertAction *action) {
                                                        }];
[alert addAction:cancelAction];    
[self presentViewController:alert animated:YES completion:nil];

请参阅documentation for UIAlertController 了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-26
    • 2015-05-19
    • 2011-04-05
    • 2023-03-09
    • 1970-01-01
    相关资源
    最近更新 更多