Skip to content

Instantly share code, notes, and snippets.

@atrinh0
Created June 27, 2021 17:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atrinh0/aca74b9200bc15f856a17027aeeb6429 to your computer and use it in GitHub Desktop.
Save atrinh0/aca74b9200bc15f856a17027aeeb6429 to your computer and use it in GitHub Desktop.
Picker Menu Style Label Issue
import SwiftUI
struct ContentView: View {
let options: [String] = ["ascending", "descending", "highest", "lowest"]
@State private var selectedOption = "ascending"
var body: some View {
NavigationView {
VStack {
Text("Image label")
Picker(selection: $selectedOption, label: Image(systemName: "line.horizontal.3.decrease")) {
ForEach(options, id: \.self) {
Text($0)
}
}
.pickerStyle(MenuPickerStyle())
Text("Text label")
Picker(selection: $selectedOption, label: Text("sort")) {
ForEach(options, id: \.self) {
Text($0)
}
}
.pickerStyle(MenuPickerStyle())
Text("Leading string")
Picker("sort", selection: $selectedOption) {
ForEach(options, id: \.self) {
Text($0)
}
}
.pickerStyle(MenuPickerStyle())
Spacer()
}
.navigationBarItems(leading:
Picker(selection: $selectedOption, label: Image(systemName: "line.horizontal.3.decrease")) {
ForEach(options, id: \.self) {
Text($0)
}
}
.pickerStyle(MenuPickerStyle())
, trailing:
Picker(selection: $selectedOption, label: Text("sort")) {
ForEach(options, id: \.self) {
Text($0)
}
}
.pickerStyle(MenuPickerStyle())
)
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
@atrinh0
Copy link
Author

atrinh0 commented Jun 27, 2021

Comparing iOS 14.5 to iOS 5 beta 2 (simulators)

picker-menu

@atrinh0
Copy link
Author

atrinh0 commented Jun 27, 2021

Comparing iOS 15.0 beta 1 to iOS 5 beta 2 (physical devices)

picker-menu2

@atrinh0
Copy link
Author

atrinh0 commented Jun 27, 2021

Affects existing apps https://apps.apple.com/us/app/id1569426267

Edit: App has been modified with a workaround, from a menu styled picker to a menu with a picker

focus

@atrinh0
Copy link
Author

atrinh0 commented Jun 27, 2021

Raised FB9214733

@atrinh0
Copy link
Author

atrinh0 commented Jul 22, 2021

Issue still exists in beta 3

@atrinh0
Copy link
Author

atrinh0 commented Jul 28, 2021

Issue still exists in beta 4

@cyrillelegrand
Copy link

Seems fixed in beta 5.

@atrinh0
Copy link
Author

atrinh0 commented Aug 11, 2021

Seems fixed in beta 5.

@cyrillelegrand still the same for me on beta 5 (on a physical device as well as simulator via Xcode 13 beta 5).

I have updated my app above with a workaround, to convert the picker (with a menu style) to use a menu (with a picker).

Same workaround is seen here: atrinh0/covid19@9e96738

@atrinh0
Copy link
Author

atrinh0 commented Sep 15, 2021

Issue still exists in iOS 15 RC, and on Xcode 13 RC.

@atrinh0
Copy link
Author

atrinh0 commented Aug 13, 2022

Issue remains in Xcode 14 beta 5, the picker shows the up/down arrows instead of using the label or leading titleKey defined.

@felix-schindler
Copy link

Thanks for the workaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment