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

我们两清 提交于 2019-12-24 06:26:11

问题


When I add one or more textField into UIAlertController the app freezes, once I deleted the textFields it works perfectly fine.

Xcode 11 beta 5 running on Mojave 10.14.6

@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)
    }
}

回答1:


I had the same problem with beta 6. Switching to a new emulator (i.e. a device I hadn't used before) temporarily solved the problem. Seems like a bug in Xcode to me. Hardware > Erase all content and settings also temporarily fixes the emulator for a while. The bug then reappears after some time.



来源:https://stackoverflow.com/questions/57509557/xcode-11-beta-5-ui-freezes-when-adding-textfields-into-uialertcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!