|
Hi, I'm having some weird issues with navigation that I am sure are down to me missing something. When I navigate around my app after navigating between around 20 links the screen goes grey. If I swipe the app up (to close it) I can see the content again. It's like some kind of overlay? Below are the contentview and one of the other views (the rest are basically the same, just load different text files). Any pointers on what I am doing wrong would be really appreciated.
|
|
I was having a same issue, i was suggested a solution by @roosterboy, this happens as the stack of backbutton grows and navigation crashes, So the solution, we need to have a NavigationView only once in our navigation cycle and find a way to never hit that View again (one with NavigationView) You will need to modify your navigation structure accordingly
My case is as FirstView --> SecondView ---> FinalView ----> FirstView So first we create a main view from where we start the navigation Main View structure called FirstView
See no NavigationView in above Now we create content View and call the firstview
Then second View
Now comes the important part from final view i will go to FirstView not the Content View to avoid hitting NavigationView
Hope this helps, good luck |
|
I don't know much about the reason why this isn't working. But since I really don't know for sure that it would help. But it might be worth looking into. |
|
@FlyOstrich - Navigation has been a bit problamatic in swiftui, this issue was there since long |
|
Thanks for the replies, I think I understand what to do. But before I go ahead, is this the normal way to navigate in a swiftui app? I didnt expect it to be this complicated. I plan to add more pages/views over time - but do I need to plan them all out in advance? It's not possible to just link between views/pages? |
|
@FlyOstrich - I thought I'd try changing it from a NavigationView to a NavigationStack - it fixed the problem. Just seems a shame to have to make the app iOS16 only. |
|
@Bigdrunk, come to think of it , its not very complicated, just switch the contentview body to some other view and call it , avoid going to NavigationView as that will cause the backbutton issue and also this grey screen ... its really a very nice clean way I had tried using @EnvironmentObject by creating a ViewRouter along with a motherView, then move from one view to other, but we miss on many baked in features .. |
|
Quick update, thank you all for your help. But I think I was trying to run before I can walk by using custom back buttons, I dont know why I went straight for those. But I'm now using the built in back button in the navigation bar, I'll revisit this but it means I can keep learning/building my app. |
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
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.