简体   繁体   English

Xcode 11 beta 5:将textFields添加到UIAlertController时,UI冻结

[英]Xcode 11 beta 5: UI freezes when adding textFields into UIAlertController

When I add one or more textField into UIAlertController the app freezes, once I deleted the textFields it works perfectly fine. 当我将一个或多个textField添加到UIAlertController时,该应用程序冻结,一旦删除了textField,它就可以正常工作。

Xcode 11 beta 5 running on Mojave 10.14.6 在Mojave 10.14.6上运行的Xcode 11 beta 5

@IBAction func addRecipeBtnHandler(_ sender: Any) {
    let alert = UIAlertController(title: "Add new recipe", message: nil, preferredStyle: .alert)

    alert.addTextField { textField in
        textField.placeholder = "title"
    }
    alert.addTextField { textField in
        textField.placeholder = "description"
    }

    let action = UIAlertAction(title: "Add", style: .default) { alertAction in
        let title = alert.textFields?.first?.text ?? ""
        let description = alert.textFields?.last?.text ?? ""

        let recipe = Recipe(title: title, description: description)
        self.recipes.append(recipe)

        self.updateSnapshot()
    }
    alert.addAction(action)

    DispatchQueue.main.async {
        self.present(alert, animated: true)
    }
}

I had the same problem with beta 6. Switching to a new emulator (ie a device I hadn't used before) temporarily solved the problem. 我在beta 6中也遇到了同样的问题。切换到新的仿真器(即以前没有使用过的设备)可以暂时解决该问题。 Seems like a bug in Xcode to me. 在我看来,似乎是Xcode中的错误。 Hardware > Erase all content and settings also temporarily fixes the emulator for a while. 硬件>擦除所有内容和设置还会暂时修复模拟器。 The bug then reappears after some time. 该错误会在一段时间后重新出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM