|
Hello, I noticed a strange behavior in the TabView with Sheets. When you launch the following ContentView:
Can anybody confirm this behavior? If so, does anyone know the solution or a workaround. Thanks and best regards Pawel |
|
Hi Pawel! Not sure what is the object you want to pass around but you can use TabView(selection:) initializer like so:
|
|
|
|
hi Pawel, just use one this works:
hope that helps, DMG |
|
It took me some time to find where I read/watched about that. I thought it was an article but turned out to be youtube video. Where the reason for that is explained. Here is the link https://www.youtube.com/watch?v=8rCtYoG9JIM, how to handle multiple sheets on the view. The solution to this is to use a model something like this:
|
|
|
|
Pawel, notice that the solution offered by @delawaremathguy is not really handling initial value passing. Just try to go to tab 4 and press the button you still will see '0' on your .sheet. This is explained in the video that I offered you to watch. The only solution I could find is creating of optional value that will trigger appearance of .sheet, but it has to be Identifiable that is why in my example I put data in struct. |
|
hi, i agree with Yuri (@ygeras) ... i forgot this subtlety. but you can work just with the Int type without the need to put in a separate struct if you do these three things: (1) make Int Identifiable.
(2) use an optional for the selected index.
(3) use the
hope that helps (and more than my last attempt) DMG |
SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.