Questions tagged [swiftui-picker]
68 questions
10
votes
4 answers
App crashes when SwiftUI view with Picker disappears (since iOS 16)
We have an application with some 'chat' functionality where questions are asked and the user can answer with some predefined options: for every question a new view is presented. One of those options is a view with a Picker, since iOS 16 this Picker…

Vama
- 208
- 1
- 13
10
votes
2 answers
SwiftUI picker driven by an enum: value not updated
According to Apple's documentation regarding Picker in SwiftUI using an Enum, if the enum conforms to the Identifiable protocol in addition to CaseIterable, a picker iterating over all cases should update the bound variable natively.
I tested it,…

alpennec
- 1,864
- 3
- 18
- 25
7
votes
1 answer
Disable specific picker items
Is there a way to disable specific picker items? In AppKit, you can disable NSPopUpButton items via the NSMenuValidation protocol, but disabling a label in the picker predictably does nothing. Just another API gap in SwiftUI?
I…

Procrastin8
- 4,193
- 12
- 25
6
votes
3 answers
SwiftUI Picker with option for no selection in iOS16
I am using Picker with option for no selection, in iOS15 it is working fine, but in iOS16 it has a default value, how can I remove this default value, I don't need to show the text to the right of the Picker line when selection is nil.
struct…

GorCat
- 174
- 3
- 11
5
votes
3 answers
Clickable area of SwiftUI Picker overlapping
I am currently trying to create a page with three adjacent Picker views inside of an HStack as seen below:
I made a CustomPicker view where I limit the frame to 90 x 240, and then use .compositingGroup() and .clipped() to make the selectable area…

Teddy Bersentes
- 166
- 1
- 10
5
votes
1 answer
SwiftUI picker title?
I'm trying to use the Picker for a simple selection. Currently I'm using the .inline navigation bar for showing the titles. (here's where i got the example https://www.hackingwithswift.com/quick-start/swiftui/pickers-in-forms)
struct ContentView:…

P. Sami
- 2,115
- 2
- 21
- 39
5
votes
2 answers
SwiftUI Picker Separators
Im trying to create a SwiftUI Picker in MacOS that looks like the ones in Xcode or other Mac Apps. To be more specific, I'm trying to add that separator line between the elements in the picker.
Like these:
I had tried several options but I can't…

xlsmearlx
- 628
- 8
- 9
5
votes
2 answers
SwiftUI Picker crashes when displayed via NavigationLink
Does anyone have a workaround for the following crash?
I have a form that is displayed via NavigationLink in a parent Navigation Controller like so:
var body: some View {
NavigationView {
NavigationLink(destination:…

Jake
- 1,756
- 1
- 12
- 7
4
votes
0 answers
SwiftUI: Cannot change background color of Segmented Control to clear?
I'm trying to change the background of a segmented control to clear but it isn't working. If I change it to a bright color like orange or blue, the color changes, but clear still leaves me with a shade of gray as a background color?
struct…

GarySabo
- 5,806
- 5
- 49
- 124
4
votes
4 answers
Deselecting item from a picker SwiftUI
I use a form with a picker, and everything works fine (I am able to select an element from the picker), but I cannot deselect it. Does there exist a way to deselect an item from the picker?
Thank you!
Picker(selection: $model.countries, label:…

Johnas
- 296
- 2
- 5
- 15
4
votes
1 answer
Picker not working when editMode is active
I have a view (Form) that, basically, has a picker and a list of items that can be re-arranged by the user. I'd like that the list is always editable, so the user doesn't have to tap en Edit button (it seems unnatural for me to have an Edit button…

cbuchart
- 10,847
- 9
- 53
- 93
3
votes
0 answers
SwiftUI Picker Options Flipped in RTL
As you can see in the attached image, the picker options are not aligned automatically to the right-hand side for RTL languages, and also flipped.
The picker is nothing fancy either, the standard way.
struct ContentView: View {
@State…

CrisAhmad
- 29
- 5
3
votes
2 answers
Align views in Picker
How do I align the Color views in a straight line with the text to the side?
To look like so (text aligned leading):
█ red
█ green
█ blue
Or this (text aligned center):
█ red
█ green
█ blue
Current code:
struct ContentView: View {
…

George
- 25,988
- 10
- 79
- 133
3
votes
0 answers
SwiftUI - Style Picker like in form
How can I style a picker to make it look like in form, but without it being nested in it?
In form picker looks like a navigation link which takes you to a separate screen where you can pick one option. I want such behaviour in list, but without…

Ilyat
- 31
- 1
3
votes
1 answer
How to set up a textfield with Picker as input in SwiftUI
I'm implementing an app which needs a very common scenario: take picker's value as input to an Textfield. With a "done" button at top right of the picker screen which could save the value to textfield. I'm using SwiftUI instead of UIKit. I see a…

TommySun
- 57
- 7