如何解决在NavigationLink的嵌套NavigationView中列出CoreData对象的正确方法
在xcode 12(swift 5.3)中,我使用条件NavigationLink导航到另一个navigationView,以使用NavigationLink列出coreData对象。但是似乎AnotherView的NavigationTitle不能正确显示在屏幕顶部,而是填充到顶部。另一个navigationView中的列表具有外部白色背景色。我想传递给SomethingView报告Argument passed to call that takes no arguments
错误的something.id,但是我可以在Text中获得something.name。
struct StartView: View {
@State var changeToAnotherView: String? = nil
var body: some View {
NavigationView {
VStack(spacing: 20) {
...
NavigationLink(destination: AnotherView(),tag: "AnotherView",selection: $changeToAnotherView) { EmptyView() }
}
}
}
}
struct AnotherView: View {
@Environment(\.managedObjectContext) var moc
@FetchRequest(entity: Something.entity(),sortDescriptors: []) var somethings: FetchedResults<Something>
...
var body: some View {
NavigationView {
List {
ForEach(self.somethings,id: \.id) { something in
NavigationLink(destination: SomethingView(somethingID: something.id)) {
Text(something.name ?? "unknown name")
}
}
}
.navigationBarTitle("SomethingList")
}
}
}
解决方法
您不需要第二个val seed: org.kethereum.bip32.model.Seed = MnemonicWords(VALID_MNEMONIC_15).toSeed()
val derivedKey = seed.toKey("m/")
assertThat(derivedKey.serialize()).isEqualTo(XPRV_OF_MNEMONIC_15)
-在视图层次结构中它只能是一个,而且最好通过引用传递CoreData对象(视图将能够观察到它),所以
NavigationView
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。