So it turns out that the completion used in the video is deprecated, instead we have to use a similar completion, which has 'content' first then the 'label'. *The issue is that now the label (content of label) won't show If we just placed the picker on it's own, we have to place it in a list for the label to show.* List { Picker(selection: $selection) { ForEach(filterOptions, id: \.self) { option in Text(option) // .font(.headline) // .foregroundStyle(.red) .tag(option) } } label: { // This will only work if our picker is in a list. HStack { Text("Filter: ") Text(selection) } .font(.headline) .foregroundStyle(.white) .padding() .padding(.horizontal) .background(.blue) .clipShape(.rect(cornerRadii: RectangleCornerRadii(topLeading: 10, bottomLeading: 10, bottomTrailing: 10, topTrailing: 10))) .shadow(color: .blue.opacity(0.3), radius: 10, x: 0, y: 10) } .background(.green.opacity(0.1)) .pickerStyle(.menu) /* Label will only show in these picker styles, when picker is in a list: - inline - menu */ } *Alternatively we can use a 'Menu' and use a different picker view completion with it. Note: This is a workaround.* Menu { Picker("Filter", selection: $selection) { ForEach(filterOptions, id: \.self) { option in HStack { Text(option) Image(systemName: "heart.fill") } .tag(option) } } .pickerStyle(InlinePickerStyle()) } label: { HStack { Text("Filter:") Text(selection) } .font(.headline) .foregroundColor(.white) .padding() .padding(.horizontal) .background(.blue) .cornerRadius(10) .shadow(color: Color.blue.opacity(0.3), radius: 10, x: 0, y: 10) }
@Ameer-pl9hl4 ай бұрын
thank you, this actually really helped 🙏🏼
@raymundoortiz72692 жыл бұрын
all programming tutorials should be like this!!, showing only 1 thing, but detailing many ways to use it... BRAVO!!!!
@Nortiz13492 жыл бұрын
iOS 16+ Put the picker in the list ex) List { Picker(selection: $selection) { ForEach(filterOptions, id: \.self) { option in Text(option) .tag(option) } } label: { Text("Filter") } .pickerStyle(.inline) // .automatic .segement whatever }
@marlhex6280 Жыл бұрын
Thanks for styling the picker! on the todoList set pages per segmentedControl
@DavidShaw-dc4re Жыл бұрын
This example no longer works in xcode 15.0.1
@afdreadbrizgaming14363 жыл бұрын
I am having a problem following along. I get all the way into the program until you Show the alternative, once you get to the @8:15 mark it gets tricky for me because Im not sure if its a different version of xcode. Im just getting into it now. I don't get the same result that you do. for some reason I still get the "1" instead of picker to come up on my view and I cannot write code for the button because it does not show up but I don't get any compilation errors when I follow along and that bothers me because I really want to understand it and I cant grasp it past that point
@rohitkulkarni46162 жыл бұрын
hey I think you and I are having the same issue, it works fine if you load it on a sim for ios 14.5 btw
@jamesgilligan67110 күн бұрын
Love the video but my only wish is that you show us what to DO with the picker. IE how it works in a function, how to call the tags, etc. Good to have a picker but if I cant do anything with it then i am stuck. Thanks again.
@jay84123 жыл бұрын
Thanks for the video, please could you do a tutorial on implementing a Contact Picker
@serhii_rs2 жыл бұрын
Thanks for the video lesson! You made my day!
@marinash2312 жыл бұрын
Thank you for your brilliant videos!
@husseinawada8845 Жыл бұрын
hello nick , the Label is not showing in the picker for xcode 14 , I've surffed the web about this problem and no one have an answer , so if you know how to solve it please upload a new video about it . thanks
@elemento_arts Жыл бұрын
I'm sure it's a bug. Can't show it either.
@erenoz8710 ай бұрын
Great content
@mhfs613 жыл бұрын
Thank you for the video. You might want to consider a video about the picker view’s behaviour in other container views, like List, Form, ScrollView. Quite challenging.
@danielwatson65293 жыл бұрын
Yea, picker is well picky. I hope this tut helps me out 🤣
@serhii_rs2 жыл бұрын
Picker for iOS is changed in iOS 16. Could you make update for this?
@arnie9405 Жыл бұрын
+1 here, the tutorial still sort of works the API seems to be the same but the rendered result is slightly different
@rohitkulkarni46162 жыл бұрын
Love this tutorial, seems as though the ability to customize the picker itself has some issues with iOS 15 (basically no matter what code you have itll just show the raw text), and this works perfectly fine if i load it onto an iOS 14.5 sim, has anyone found a way to make it work? I've seen a workaround to use Menu instead of picker but given the amount of people facing the issue i find it odd its been like this and also so close to iOS 16 release
@mattbinkowski33103 жыл бұрын
Any thoughts on how to populate the picker when you've previously saved the selection in CoreData?
@SwiftfulThinking3 жыл бұрын
Hi Matt! This is very possible. You first need to download the data from CoreData, store it in an array, and then reference the array in your Picker! I will be doing a few videos on CoreData in the next week or two.
@raymundoortiz72692 жыл бұрын
Very good video!!!
@andresraigoza20823 жыл бұрын
I love your way of teaching, thank you so much!!! I wanted to ask you. I am using Xcode 13 and now the label in the MenuPickerStyle does not show up on the screen. Do you know why?
@SwiftfulThinking3 жыл бұрын
Are you using the initializer with a Picker and a "label" ? It should still work in Xcode 13.
@andresraigoza20823 жыл бұрын
@@SwiftfulThinking Yes I am using picker with label. I found a way to do it on stack overflow, this is the code: Menu { Picker("Filter", selection: $selection) { ForEach(filterOptions, id: \.self) { option in HStack { Text(option) Image(systemName: "heart.fill") } .tag(option) } } .pickerStyle(InlinePickerStyle()) } label: { HStack { Text("Filter:") Text(selection) } .font(.headline) .foregroundColor(.white) .padding() .padding(.horizontal) .background(.blue) .cornerRadius(10) .shadow(color: Color.blue.opacity(0.3), radius: 10, x: 0, y: 10) } Do you think this is a good solution?
@AndresGutierrez-nb6qr Жыл бұрын
@@andresraigoza2082 Thank you for this work around 😉
@frankz29332 жыл бұрын
I tried just now, and I found these modifiers for picker label don't work any more. -_-
@deanspann81632 жыл бұрын
Would it be possible for you to create a tutorial on creating dropdown pickers and storing that data in a firebase collection? Essentially creating a collection for user profile information, and then create a variable for gender that is displayed as a dropdown picker in the UI interface.
@marvinmeinhard4711 Жыл бұрын
Thank you for these Tutorials! Is there any native functionality to have a picker that allows multiple selections? e.g. whe i want a user to be able to select up to 3 options at a time? it seems that you have to build a workaround using a list...
@ostanjaffcompany1733 жыл бұрын
Previously I tried this, but it doesn't work in a subview where a @Binding is used, It can only be used where the selected is kept in an @State variable, so it is not very useful as if it is used in the main view, this will be applied in all the pickers. init() { UISegmentedControl.appearance().selectedSegmentTintColor = UIColor.red UISegmentedControl.appearance().setTitleTextAttributes([.foregroundColor : UIColor.white], for: .selected) } Thanks anyway, I hope you can keep it up.
@SwiftfulThinking3 жыл бұрын
Yea,
@chuansun12693 жыл бұрын
讲得不错 ,对我帮助很大,谢谢你
@TeemoChan Жыл бұрын
This is how I did it to costumes the picker for the new update , I embedded the picker inside a menu {} label{} : @State var selectedNumber: Int = 0 var body: some View { Menu { Picker(selection: $selectedNumber , label: EmptyView()) { ForEach(0..
@vedantk235 ай бұрын
Hey Nick, Is there any way to change the segmentColor without using UIKIT ?
@knowledgeispower495310 ай бұрын
Good bro..☺
@muradjam Жыл бұрын
can you change the font of the Text in the picker (style = MenuPickerStyle) ?
@irfanrizvi1613 жыл бұрын
Hi Nick, How do I make this Picker() select onLoad a default value from the filterOptions array?
@SwiftfulThinking3 жыл бұрын
Hey Irfan, you just need to set the "selection" to whatever value you want it to start at!
@dikshagaonkar17973 жыл бұрын
How to create a pickerview with multiple selection? Please help if possible
@SwiftfulThinking3 жыл бұрын
Hi Diksha, this is not a feature that's build into SwiftUI. You would have to make a custom picker, which is much more advanced. I will be covering some customizations like this in my SwiftUI Advanced Learning course coming soon.
@bigfoot1312 жыл бұрын
Hi. Am currently teaching myself swift using ur tuts all is smooth apart from this picker is there another way to implement it am using Xcode 13.4 and apparently the picker is working but not the label part the text component and it’s modifiers.
@MahidAli65 ай бұрын
can we increase height of picker segment?? also the color of segement of picker isn't changing...
@mykosen56792 ай бұрын
To change the height, you can add this to the initializer: UISegmentedControl.appearance().setContentHuggingPriority(.defaultLow, for: .vertical) And then you'll be able to change the height with .frame(height: 100) for example.
@vladimirmoor3 жыл бұрын
Thanks for the video. A little comment: is iOS13 you can use only a wheel picker.
@Whyhardable2 жыл бұрын
How would you get this picker to display on a ViewController?
@billsouthwick81232 жыл бұрын
I’m running iOS 15 and Xcode 13. In my first picker the picker is going from 99 to 18 even though I have 18..
@raymundoortiz72692 жыл бұрын
Is it possible chance the strings inside the picker for ICONS or images?
@JeckyKA3 жыл бұрын
awesome, thanks a lot!
@katoaapps53762 жыл бұрын
Idk if I'm just broken or what but I have the exact same code running 15.2 emulator with xcode 13.2.1 and the style for the picker doesn't change from the default button blue text
@TheSpiralnotizblock2 жыл бұрын
Thats a bug from SwiftUI
@abdullahkardas88872 жыл бұрын
accentColor will change it
@clewis92232 жыл бұрын
Hi Nick, great video as always but I am afraid there is a big issue when placing two pickers side by side. The select overlays hit boxes clash and you have to select before the picker or after the picker to update the number. Luckily someone has provided an extension override. extension UIPickerView { open override var intrinsicContentSize: CGSize { return CGSize(width: UIView.noIntrinsicMetric, height: super.intrinsicContentSize.height) } }
@RahulSingh-s2m Жыл бұрын
editing on label is not working buddy in my code
@prabhakaryadav17599 ай бұрын
deprecated init format
@MrSkyydude2 жыл бұрын
You can pick your nose. You can pick your friends. But you can't pick your friends' nose.
@Horizon-tr6iy2 жыл бұрын
14:50
@robertmartens78393 жыл бұрын
indices is pronounced IN-DUH-SEES
@SwiftfulThinking3 жыл бұрын
😰 I really shoulda known that LOL c'est la vie.
@chezchezchezchez Жыл бұрын
For the love of God, stop saying "a-TRIB-utes" We stress the FIRST syllable with the word: attributes.
@rdr9999Ай бұрын
Because that’s what’s important here 🙄
@lowlydeveloper369329 күн бұрын
I think Nick has a license to pronounce "attributes" any way he likes considering the quality of his lessons. In fact, I am perfectly fine with "forward/backward slashes". Whichever. Don't matter. Just keep teaching the way you teach, Nick!