I would like to have a picker who is like involved in form{}. It should look like it's a navigation link. that problem is if I program it into a form{}, then it is scrollable and I do not want that. I want to have it static, Or one knows a solution how to make forms static and not scrollable.
XCode 11 Beta 6
@Daniel Ryan I have now programmed my own method, which works very well.
import SwiftUI
var AnArrays : [String] = [ "eins", "zwei", "drei", "vier", "fünf"]
struct ContentView: View {
@State var Gepickt : String = ""
var body : some View {
NavigationView{
VStack {
NavigationLink(destination: AuswahlPick(gewählt: $Gepickt)) {
HStack {
Text("PickerMaSelf")
.foregroundColor(Color.black)
Spacer()
Text(Gepickt.count > 0 ? Gepickt : "Pick One ?") .foregroundColor(Color.gray)
Image(systemName: "chevron.right") .foregroundColor(Color.gray)
.padding(.trailing)
}
}
}
}
}
}
struct AuswahlPick: View {
@Binding var gewählt : String
@Environment(\.presentationMode) var presentationMode
var body: some View {
Form{
ForEach(AnArrays, id: \.self){ x in
Button(action: {
self.gewählt = "\(x)"
self.presentationMode.wrappedValue.dismiss()
}) {
Text("\(x)")
.foregroundColor(Color.black)
}
}
}
}
}
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif