warnings - 关闭时的 UIAlertView 警告

标签 warnings sprite-kit uialertview dismiss skscene

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

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

工作正常。但是,当我单击“确定”按钮关闭警报时,我得到以下信息:

警告:在演示或关闭过程中尝试从 View Controller <_UIAlertShimPresentingViewController: 0x16ea2230> 关闭!

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

  • 任何想法为什么会发生此警告?我不想忽略它,以防它在 future 版本的 iOS 中变成 fatal error 。

    更新

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

    最佳答案

    我得到了同样的警告:

    警告:尝试从 View Controller <_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了解更多信息。

    关于warnings - 关闭时的 UIAlertView 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24747640/

    相关文章:

    java - HttpClient 警告 : Cookie rejected: Illegal domain attribute

    Java 弹出窗口说应用程序包含未签名和已签名的代码

    ios - 在 Swift + Sprite Kit 中更改场景的最简单方法

    ios - 一次检测多个触摸(Swift)

    ios - 使用 SpriteKit 创建 2D 液体

    iphone - 改变 uialertview 大小的问题

    iphone - 如何使用 CALayer : Trying to draw a Layer in my Application

    ios - 在 GameScene 中显示 UIAlertController (SpriteKit/Swift)

    ios - 复制 UIAlertView 时;背景不一样

    c# - ReSharper 警告 - 访问修改后的闭包