如何一个接一个地制作listview? - Swift
How to make a listview one after another? - Swift
我正在尝试一个接一个地制作列表视图,但这种情况一直在发生。有没有办法去掉一个后退按钮,只显示一个? swift 是否有一种功能可以像隐藏导航视图那样删除后退按钮?这是它的样子:
他是我用于原始列表的代码:
@ViewBuilder func jsonSelector(using id: Int) -> some View {
switch id {
case 1:
SCaliView()
case 2:
BAView()
case 3:
DesertView()
case 4:
NCoastView()
case 5:
CCoastView()
case 6:
SVView()
case 7:
SNView()
default:
ContentView()
}
}
// MARK: - BODY
var body: some View {
ZStack {
VStack() {
NavigationView {
Group {
List {
ForEach(regions) { regions in
NavigationLink(destination: jsonSelector(using: regions.id)) {
RegionButtonView(regions: regions)
}
}
} //: LIST
} //: GROUP
.navigationBarTitle("Region", displayMode: .large)
.navigationBarHidden(true)
} //: NAVIGATION
Spacer()
} //: VSTACK
} //: ZSTACK
.ignoresSafeArea(.all, edges: .top)
.ignoresSafeArea(.all, edges: .bottom)
这是我用于第二个列表的代码:
ZStack {
NavigationView {
Group {
List {
ForEach(sclocations) { sclocations in
NavigationLink(destination: SCDetalView(sclocations: sclocations)) {
SCButtonView(sclocations: sclocations)
}
}
} //: LIST
.navigationBarTitle("Region", displayMode: .large)
.navigationBarHidden(true)
}
} //: NAVIGATION
}
.ignoresSafeArea(.all, edges: .top)
.ignoresSafeArea(.all, edges: .bottom)
您只需要在第一个视图中使用 NavigationView
从详细视图中取出 NavigationView,它会正常工作并删除重复的后退按钮。
ZStack {
Group {
List {
ForEach(sclocations) { sclocations in
NavigationLink(destination: SCDetalView(sclocations: sclocations)) {
SCButtonView(sclocations: sclocations)
}
}
} //: LIST
.navigationBarTitle("Region", displayMode: .large)
.navigationBarHidden(true)
}
}
.ignoresSafeArea(.all, edges: .top)
.ignoresSafeArea(.all, edges: .bottom)
我正在尝试一个接一个地制作列表视图,但这种情况一直在发生。有没有办法去掉一个后退按钮,只显示一个? swift 是否有一种功能可以像隐藏导航视图那样删除后退按钮?这是它的样子:
他是我用于原始列表的代码:
@ViewBuilder func jsonSelector(using id: Int) -> some View {
switch id {
case 1:
SCaliView()
case 2:
BAView()
case 3:
DesertView()
case 4:
NCoastView()
case 5:
CCoastView()
case 6:
SVView()
case 7:
SNView()
default:
ContentView()
}
}
// MARK: - BODY
var body: some View {
ZStack {
VStack() {
NavigationView {
Group {
List {
ForEach(regions) { regions in
NavigationLink(destination: jsonSelector(using: regions.id)) {
RegionButtonView(regions: regions)
}
}
} //: LIST
} //: GROUP
.navigationBarTitle("Region", displayMode: .large)
.navigationBarHidden(true)
} //: NAVIGATION
Spacer()
} //: VSTACK
} //: ZSTACK
.ignoresSafeArea(.all, edges: .top)
.ignoresSafeArea(.all, edges: .bottom)
这是我用于第二个列表的代码:
ZStack {
NavigationView {
Group {
List {
ForEach(sclocations) { sclocations in
NavigationLink(destination: SCDetalView(sclocations: sclocations)) {
SCButtonView(sclocations: sclocations)
}
}
} //: LIST
.navigationBarTitle("Region", displayMode: .large)
.navigationBarHidden(true)
}
} //: NAVIGATION
}
.ignoresSafeArea(.all, edges: .top)
.ignoresSafeArea(.all, edges: .bottom)
您只需要在第一个视图中使用 NavigationView
从详细视图中取出 NavigationView,它会正常工作并删除重复的后退按钮。
ZStack {
Group {
List {
ForEach(sclocations) { sclocations in
NavigationLink(destination: SCDetalView(sclocations: sclocations)) {
SCButtonView(sclocations: sclocations)
}
}
} //: LIST
.navigationBarTitle("Region", displayMode: .large)
.navigationBarHidden(true)
}
}
.ignoresSafeArea(.all, edges: .top)
.ignoresSafeArea(.all, edges: .bottom)