The Complete Guide to NavigationView in SwiftUI
Вставка
- Опубліковано 22 сер 2024
- NavigationView is one of the most important components of a SwiftUI app, allowing us to push and pop screens with ease, presenting information in a clear, hierarchical way for users.
In this video I want to demonstrate the full range of ways you can use NavigationView in your apps, including simple things like setting a title and adding buttons, but also programmatic navigation, creating split views, and even handling other Apple platforms such as macOS and watchOS.
Tip: In production applications you should be careful about creating reference types locally to a view, and should have a separate model layer for them.
Thanks to RevenueCat for sponsoring this video - check out their docs to learn more and get started: docs.revenueca...
2 days of struggle and your video solved my issue in first 1 min and 43 sec. Thank you sir!!!
Thanks so much for the video! With the deprecation of NavigationView and release of NavigationStack, are you planning a similar video for the Stack variant and new way of working with Navigation?
Excellent tutorial. I always learn so much when I watch your videos.
Good stuff paul, I wish you went deeper into advanced stuff like "tag", popping back to root..ect
Perfect timing! All I've been seeing online lately are endless complaints re: nav in SwiftUI.
Thanks to this video, I could finally finish my authentication flow navigation where protected tab to redirect to signIn page!!
Dear Mr.Hudson, thank you very much indeed for this tutorial. I've been on the UIKit before, and before seeing this tutorial, I have struggled to comprehend the navigation concept in SwiftUI. Now it's crystal clear to me - thanks to your kind help!
There are no more ‘h’ in the world, you used it all :) Great video, by the way. Thank You!
Thank you so much for making this video, I learned a lot of stuff that I needed. I owe you this one!
You are made out of greatness. Thank you for the tutorials.
Paul you're the king.
You are incredible. Thank you sir ,we love you
Awesome guide to NavigationView in SwiftUI, Paul! Thanks for sharing.
Great tutorial and I especially like the workarounds you came up with to allow us to keep the same code between platforms. However, when you build the watchOS version at 35:26, you haven't re-inserted the NavigationView code in the main ContentView to demonstrate that the struct has "fixed" the watchOS limitation.
You're a legend. Keep it up!
Thanks for this Video helped me a lot
its like my head can't check all the things you're sharing, so I will needed to come back to rewatch
Wish you the best and stay active this Videos help a lot for everybody and nice and simple explanations great Job
Many thanks for your comprehensive tutorials. Really good!
your courses are awesome!! keep going!
Love your videos... ❤️
Very detailed, no BS!
Wonderful! I always learn something new thanks to you.
It helped me a lot!
Amazing tutorials! Thanks for all your efforts in giving excellent examples.
What great timing Paul. I have been going over this for a couple days now,, thank you. Are you hacking my computer? If you are great job! Lol. I am wondering how I take this knowledge and when I navigate to the second screen instead of the simple text views import PDF or JSON data.
Amazing. Super complete!
just majestic
Always very interesting, a lot of new things to learn
You are awesome ! Thank you very much for this video 😃
thanks a lot for the video.
such an informative lesson - thank you very much!
Fantastic job. Thank you!!
I started to watch all of your videos, all are great and really helpful, one question on this video, at 17:35 timeline, why @ObservedObject is used, in an another video you advised to use the @StateObject instead of @ObservedObject while creating the object, and use @ObservedObject only while passing data. Hope you will clarify this to me, and thanks in advance
Thank you Paul. awesome stuff
Amazing video.....
Fantastic video! 👍
Fantastic video. Just transitioning to SwiftUI, so this is extremely helpful. Just one minor oversight in your video in the WatchOS example at 35:30. You made a nice wrapper to take care of the fact that watchOS doesn't support NavigationView. Unfortunately, just before you created your watchOS-specific NavigationView, you deleted the NavigationView from the body of your ContentView example. In other words, you didn't use the wrapper you created. I'm sure it would have worked, though!
Also, I'm a little confused about your macOS example. You got the macOS version of the code to compile by implementing the navigationBarTitle modifier, but that implementation does nothing. Presumably, you want to do something with that title. If you wanted to simply remove the offending modifier, I think you just wrap the modifier with the conditional compiling without having to create an extension.
Thanks! Learned a ton!
Thank you, Paul! This material is very helpful. But I have a question, it is possible to set attributes for buttons as well? I want to change color of backButton, it shall be different for scrollEdgeAppearance and standardAppearance in my case. Thank you in advance, regards.
Hi!!! As always awesome content I have a question, let's suppose I have navigation of 3 consecutive views, view 1 -> view 2 -> view 3, and being in the view 3 how can I perform a popToRootViewController in swiftUI so I can get to view 1
Just perfect! Congratulations!
Es un vídeo fantástico!!! Muchas gracias Paul
Bless you Sir.
Great video!
always helpful !!!
Thank you so much , appreciate!
This is great! Do you know if with SwiftUI you can keep open the primary view for iPad when having the master/detail views? Thanks!
Awesome stuff!
Thank you!
Paul, I love your videos. Can you also please do a video on how to type as fast as you? :-)
That's me typing slowly! I only type fast when I'm a) using my mechanical keyboard, and b) not trying to narrate a 40-minute video in one take 😅
I really like your videos!
I don't understand why to use EnvironmentObject when i can just use a singleton managers like "UserManager.shared.score" without passing any data between the views.
The UserManager.shared.score variable can be @Published type and thats it, no?
Does SwiftUI have a way to drag and drop UI comps to quickly learn the basic elements? Learning Swift UI now, live preview is nice but it’d be nice to drag and quickly see what the different controllers / controls do and how they look.
It is a very good video but there is an interesting point which is not addressed I think. How do we programmatically go back?
Great and informative like always but is there a way to hide the primary view and keep only the secondary on screen in a Catalyst app on macOS. Like Reminder is doing it if you resize the primary view to zero.
Is there a way to replace the title text (on the parent page) with an image, but keep the navigation link button appearing on the child page to return you back to the parent page?
12:20 I don't understand why/when we'd use this. Is this just another way of doing the same thing you showed before, or is this required for certain situations? If so, *which* situations? That's not at all clear.
You are missing the case where I want to navigate to a new view WITHOUT the back button, thereby reseting the entire navigation stack. ie Loggin in, signing out.
you are the best .....
very helpfull tnx bro
The MAN...
How if I would like. .navigationViewStyle(DoubleColumnNavigationViewStyle()) and make portrait view to show 2 columns as same as landscape view on iPad ? thankssss ^^ please help
Is it possible to remove the default top navigation space ? Thanks
NavigationLink with isActive is deprecated now. Is there an updated video?
Thank you Paul. How do you find such things? Is there any way to create nav bar title views? Or it not exists in SwiftUI and we must draw all manually?
Hello sir!
how navigate back to a specific view?
A->B->C->D->B
How can I navigate by click on the image from example?
Thanks for this awesome video. I am trying to create a login screen with colored background. I have 2 buttons in my login view in a Vstack, and that Vstack sits within the NavigationView. When I try to give my Vstack a background color, the background of the VStack doesn't take up the entire screen. It seems like the navigation view is hogging space at the top of the screen. Do you know how to stop this? I can't find any documentation on it.
Use a Zstack with the colour and the navigation view
Great video, man! I still hate swift though. hahahahaha
I tried programmatically popping from the details view to the main view. But, when I implement that the back navigation on the top does no longer work.
Hi Paul is there a "shimmy" ? for detecting an iPad or an iPhone? or would it be better to write 2 SwiftUI files - one for each device type?
Wow, thank you very much. How many hours should I do coding for, to write code without any googling like you?
Paul, With Xcode12 beta, AppDelegate is no longer available, so I am confused how we tackle to the navigation bar attributes.
Hi Paul, thanks for the content. I just wanted to say that the micro phone static is a tad off putting, every time you chat it crops up.
It's actually the fan from my MacBook Pro - it runs hot because of Xcode, plus screen capture, webcam, etc. I have switched out my mic since then, which ought to help 👍
@@twostraws Awesome! Great content really enjoying it.
Very interesting. But Apple should make sure that SwiftUI just can be used on all devices without change or additional platform code! This is still in a beta stage for me
Hi there, love your channel. I enjoy every episode. However, that would be wonderful if you would have left the source code for the tutorial.
how can we hide back button in view
After 25:15 I understood, its not my cup of tea. Thanks
Is there a reason you use the XCode Simulator instead of the live preview in Canvas?
Is there a quicker way to embed in NavigationView like there is with embed in HStack, etc.?
how to access Observed object inside observable class
Hey Paul, do you have an update for the Swift UI 2 new NavigationTitle and associated styling, NavigationBarTitle has been deprecated.
Is transcript for the video available.
hey ... random question ... how can you make a clone of notion or taskade.com ?
Hey, Paul - If you're gonna update, PLEASE, for the sake of anyone like me, who has no choice but to support older hardware (and therefore, older software, tools and coding practices) put the update *ALONGSIDE* the original, instead of junking and replacing the old version! That doesn't just apply to this vid - I'm also speaking of your material on the HWS website, which, granted, is some serious good stuff, but for those of us who don't or can't work exclusively on hardware (and therefore, software and tools) that's bleeding-edge-just-released-yesterday, losing the "old" tutorials and docs because they've been updated to this week's "latest and greatest" is a serious kick in the guts.
All the old iOS 15 and even iOS 13 videos remain on UA-cam, SwiftUI by Example shows both new code and old code wherever possible, and folks who buy Hacking with iOS get both the new book and the old book as part of their purchase - it’s hardly what I’d call “junking and replacing.”
@@twostraws You seem to have taken that as some sort of personal jab - That was NOT the intention. More of an observation that everybody and his dog who puts out tutorials, examples, and docs seems to be obsessed with punching out a new version every time Apple hints at a new software version number, and in the process, dumps us "not the blood dripping off the bleeding edge" folks like a hot rock.
Hi Paul,
I've been trying to use a ZStack and NavigationView together. I'm using a Maps/Stocks drawer view that starts with the handle at the bottom of the screen and covers a NavigationView. The NavigationView behaves very strange when you do this. The navigationBarTitle and the buttons disappear. I figured out that they just got pushed up above the top of the screen. I ended up with a ZStack - VStack - Spacer - NavigationView - then the custom drawer view for the top of the ZStack. It kind of works.... Looks good on 11 Pro Max but doesn't fit the screen on the other devices and the drawer disappears . From what I have been able to figure out NavigationView should be at the top of the order but that doesn't work either. Any Ideas on how to make this work?
How is "isActive" work ? I dont konw
You had my full support until 30:53. That is absolutely horrendous default behavior and makes absolutely no logical sense. I can understand why that can be useful in some cases, but as the default and recommended way? You hurt my brain with that haha.
Very Cool but I don't think this navigationBarTitle inside the NavigationView makes any sense at all.If you want it to change on the fly you should create some @State variable since swiftui introduce it.
why do swift youtubers never show link to source code in description?
can you show us how to implement in-app subscription with free trial with revenuecat. bought your power pack but it doesn't have in-app-purhcase stuff at all !!
TextEditor(text: $text)
does not work in ScrollView !
I tried to replicate the code for EnvironmentObject just like in the video, but cannot get it to work anymore. It complains that no ObservableObject of type User found. A View.environmentObject(_:) for User may be missing as an ancestor of this view.
Did Apple change something since this video was published?
Here's the code for the basic example I was testing: gist.github.com/thezealousfool/5b7ca821c478cffe180177cd748a3abd
Can you please help? Thank You
Why does “$selection work?
when we use two way bind we have to use that $ sign with variable.
NavigationView is feeling very limiting...
Do same for UIKIT (swift) also and thanks for the content xd
boom.
SwiftUI syntax, layout and the idiosyncrasies are pathetic. I can’t believe Apple is behind this abomination.
Love your tutorials, but this one is useless. Just does not align with all the other methods or tutorials on how to navigate or create views. Totally confusing. Thumbs down.
AppDelegate.swift is no long created by XCode. Have to add the UINavigationBarAppearance codes in the "mainApp' file using init() {...}
You never showed how to automatically move to a new view.