Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Picker on iPadOS 15 beta 8
For anyone else running into this, it's not hard to convert from a Picker with MenuPickerStyle to a Menu. I went ahead and converted the above to demonstrate: struct OuterView: View {     @State var colorViewModel = ColorViewModel()     var body: some View {         ColorView(colorViewModel: colorViewModel)     } } class ColorViewModel: ObservableObject {     @Published var colors = ["yellow", "green", "blue"]     @Published var selectedColor = "Select a color" } struct ColorView: View {     @ObservedObject var colorViewModel: ColorViewModel     var body: some View {         VStack {             Menu {                 ForEach(colorViewModel.colors, id: \.self) { color in                     Button(color) {                         colorViewModel.selectedColor = color                     }                 }             } label: { Text(colorViewModel.selectedColor)                 .frame(maxWidth: .infinity, alignment: .leading)                 .padding()             }             .border(Color.black, width: 2)             Text(colorViewModel.selectedColor)         }         .padding()     } } struct ColorView_Previews: PreviewProvider {     static var previews: some View {         OuterView()     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’21
Reply to SwiftUI Picker on iPadOS 15 beta 8
We are seeing the same issue on our app. Was hoping that this would be fixed before iOS 15 is released... probably next week or soon? Do we need to hot fix our application to support this type of picker style?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to SwiftUI Picker on iPadOS 15 beta 8
For anyone else running into this, it's not hard to convert from a Picker with MenuPickerStyle to a Menu. I went ahead and converted the above to demonstrate: struct OuterView: View {     @State var colorViewModel = ColorViewModel()     var body: some View {         ColorView(colorViewModel: colorViewModel)     } } class ColorViewModel: ObservableObject {     @Published var colors = ["yellow", "green", "blue"]     @Published var selectedColor = "Select a color" } struct ColorView: View {     @ObservedObject var colorViewModel: ColorViewModel     var body: some View {         VStack {             Menu {                 ForEach(colorViewModel.colors, id: \.self) { color in                     Button(color) {                         colorViewModel.selectedColor = color                     }                 }             } label: { Text(colorViewModel.selectedColor)                 .frame(maxWidth: .infinity, alignment: .leading)                 .padding()             }             .border(Color.black, width: 2)             Text(colorViewModel.selectedColor)         }         .padding()     } } struct ColorView_Previews: PreviewProvider {     static var previews: some View {         OuterView()     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21