ios - EXC_BAD_ACCESS with navigation bar title in SwiftUI
问题描述
I'm getting a crash on my iPhone (but not in simulator) whenever I include a navigation bar title in my SwiftUI view. If I take out the navigation bar title everything works just fine, but I need the title there. Here's my code:
NavigationView {
List {
ForEach(self.viewModel.tasks) { task in
TaskRow(task: task)
}
.onDelete(perform: self.viewModel.delete(indexSet:))
}
.listStyle(.grouped)
.edgesIgnoringSafeArea(.bottom)
.navigationBarTitle(Text("mainTitle")) //EXC_BAD_ACCESS crash here
}
UPDATE
I stripped the code above down and started a new project to make sure it wasn't my custom UI or my business logic doing something weird. The code below produces the same crash on my iPhone.
struct ContentView : View {
var body: some View {
NavigationView {
List {
ForEach((0...10).identified(by: \.self)) { val in
Text("test")
}
}
.listStyle(.grouped)
.edgesIgnoringSafeArea(.bottom)
.navigationBarTitle(Text("Hey"))
}
}
}
Any idea why this is happening or how to fix it?
解决方案
我解决了这个问题。我正在使用 Xcode 11 beta 1 构建,但我的 iPhone 运行的是 iOS 13 beta 2。由于 Swift 框架现在已内置到 iOS 中,因此我手机上的 Swift 框架(使用 beta 2 sdk)正在执行我的 iOS 应用程序(使用编译beta 1 sdk) 没有预料到。一旦我升级到 Xcode 11 beta 2,一切正常。
推荐阅读
- python-3.x - Django查询中的三元运算符不起作用
- spring-cloud-dataflow - 我们可以使用在多个节点中运行的基于 Spring Cloud 的微服务作为 SCDF 应用程序吗?
- java - 如何检索核心的子模块属性?
- javascript - 执行 XHR 请求时,如何防止应用程序布局呈现两次?
- dictionary - 从文件加载服务器名称时,Nginx 无法解析服务器名称
- flask - 在搜索期间将 SQLAlchemy 表列传递给 Flask 路由
- audio - 在与音频播放同步的脚本中突出显示文本
- c++ - 两个词有多相似?
- javascript - 从数据库中的iso日期获取日期和年份
- c++ - 如何初始化指向在映射中用作值的类中的函数的指针?