|
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.
|
|
BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.
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.