如何解决SwiftUI 导致 AttributeGraph 前提条件失败:属性值类型无效:列表中的 54808
我有一个自定义列表,用于显示领域数据库中的值,但是每当我在列表上配置 .sheet 属性时,只要用户点击该行就会显示工作表。但是,每当我添加 .sheet
时,应用程序都会立即崩溃,导致以下错误:
2021-07-18 11:56:15.978645+0530 mongodb-swiftui[21360:965109] [error] precondition failure: invalid value type for attribute: 54808 (saw ListView,expected PreferenceKeys)
CoreSimulator 772.1 - Device: iPhone 12 Pro (A078F6C3-6036-4065-93D4-01495735E0FA) - Runtime: iOS 14.5 (18E182) - DeviceType: iPhone 12 Pro
AttributeGraph precondition failure: invalid value type for attribute: 54808 (saw ListView,expected PreferenceKeys).
(lldb)
import SwiftUI
struct ListView: View {
@State var date:String?
@State var title:String?
@State var mood:String?
@State var isOpen: Bool = false
var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 25,style: .continuous)
.fill(Color.gray)
HStack {
vstack(alignment: .leading){
Spacer()
Text(date!)
.foregroundColor(.black)
Text(title!)
.foregroundColor(.black)
.font(.title)
Text(mood!)
.font(.title2)
.foregroundColor(.white)
Spacer()
}
.padding()
Spacer()
Text("Info")
.foregroundColor(.blue)
.onTapGesture {
isOpen.toggle()
}
Spacer()
}
.sheet(isPresented: $isOpen){
LoginView()
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。