swiftui - SwiftUI Picker 导航到 Core NavigationView 而不是调用它的 View
问题描述
我一直在绞尽脑汁想弄清楚是什么原因造成的,我假设它与 NavigationView 所在的位置有关。
要添加上下文,我有一个视图,我们将其称为 View A,其中包含 NavigationView。在视图 A 中有一个带有导航链接的工具栏,该链接调用以下代码片段所在的视图 B。当点击下面的选择器时,它会移动到一个视图以选择选择器选项,但在点击一个选项时,它会返回到视图 A 而不是视图 B。
添加包装此表单的附加 NavigationView 确实解决了问题,但不是我所说的理想,因为它添加了额外的标题栏。
//The following form contains all of the form components to compose the add MetaList View
Form{
Section {
TextField("MetaList Name", text: $newMetaListName)
}
Section(header: Text("Description")){
TextEditor(text: $newMetaListDescription)
}
//The following section contains the picker to determine the type of list being created
Section {
Picker("MetaList Type", selection: $metaListType) {
//The following for each utilizes the Enum detailed in MetaListModels to create an item for each case
ForEach(MetaListTypes.allCases) { metaListType in
Text(metaListType.name).tag(metaListType)
}
}
}
//The following is a placeholder section for future tags
Section(header: Text("Tags")){
}
Button(action: {
if newMetaListName.isEmpty {
metaListNameBlank = true
} else {
metaListNameBlank = false
addMetaList()
}
}) {
Text("Submit")
}
#if os(iOS)
.alert("Name Field Cannot Be Left Blank", isPresented: $metaListNameBlank) {
Button("OK", role: .cancel) { }
}
#endif
.padding()
}
.navigationTitle("Create New MetaList")
}
我非常感谢任何帮助,因为我不太确定还能尝试什么。
解决方案
推荐阅读
- javascript - Firefox 排序数组错误
- javascript - 避免许多 if 语句的最佳方法是什么?
- java - 如何使用 xslt 将父节点命名空间复制到子元素?
- symfony - 我无法在 Symfony 3.4 中使用 Monolog 的特定通道将日志写入文件
- bash - 在 bash 中的命令之前设置变量
- javascript - 刷新页面返回 [object CSSStyleDeclaration]
- php - 如何通过 cPanel 将网页永久重定向到另一个网页
- sql - 获取 emolyee 的主要(主要)、次要和三级功能
- libgdx - 如何让两个或多个不同的字体文件在 libgdx 中使用一个通用的 Atlas?
- c# - 带有 Selenium 代理设置的 FiddlerCore