|
Hey there i'm try to change my url from a Picker but i can't get it to work. Can anyone please help me? Here is the code:
|
|
Hi Lamin, if I add a Text below your Picker the City is changed accordingly. So could you please specify what does not work?
|
|
Please see the image below: The right side of the app has time and the time should change according to which city the user chooses. It only works with a normal Picker that shows a NavigationView with a list of the cities. |
|
With your provided code example I can't see how the list is actually created and where the possible error is. |
|
This is the whole code:
|
|
It seems you copied this code from somewhere but you forgot to implement your data structure for the JSON you want to decode:
In this line the |
|
|
|
Hi Lamin, I've found a solution and an explanation why these Picker styles work different. You load the data onAppear. This fires only if the view appears. With the default picker the view changes, you select the city, go back and the view changes again. With the segmented picker the view appears only once and therefore the view loads the data only once. Regardless your selection in the picker. I wasn't able to use the .onTapGesture for the picker because it seems it interferes with the built in gesture recognizer for the picker.
|
|
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.