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...

КОМЕНТАРІ • 108

  • @cainosaurous_rex4642
    @cainosaurous_rex4642 2 роки тому

    2 days of struggle and your video solved my issue in first 1 min and 43 sec. Thank you sir!!!

  • @garrettlovetv
    @garrettlovetv 2 роки тому +3

    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?

  • @dennissargent7733
    @dennissargent7733 4 роки тому +5

    Excellent tutorial. I always learn so much when I watch your videos.

  • @yixe2253
    @yixe2253 4 роки тому +13

    Good stuff paul, I wish you went deeper into advanced stuff like "tag", popping back to root..ect

  • @rgenericson5361
    @rgenericson5361 4 роки тому +9

    Perfect timing! All I've been seeing online lately are endless complaints re: nav in SwiftUI.

  • @hyounoosung7600
    @hyounoosung7600 3 роки тому

    Thanks to this video, I could finally finish my authentication flow navigation where protected tab to redirect to signIn page!!

  • @antonlebedev2890
    @antonlebedev2890 2 роки тому

    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!

  • @arnoczkyzoltan6158
    @arnoczkyzoltan6158 3 роки тому

    There are no more ‘h’ in the world, you used it all :) Great video, by the way. Thank You!

  • @miguelfelipedias
    @miguelfelipedias 3 роки тому +5

    Thank you so much for making this video, I learned a lot of stuff that I needed. I owe you this one!

  • @ZoomerAction
    @ZoomerAction 2 роки тому

    You are made out of greatness. Thank you for the tutorials.

  • @eliymim
    @eliymim 3 роки тому

    Paul you're the king.

  • @HuyLe-hn9le
    @HuyLe-hn9le 2 роки тому

    You are incredible. Thank you sir ,we love you

  • @JasonMitchellAZ
    @JasonMitchellAZ 4 роки тому +2

    Awesome guide to NavigationView in SwiftUI, Paul! Thanks for sharing.

  • @hopegrant1167
    @hopegrant1167 4 роки тому +5

    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.

  • @kingkevin23
    @kingkevin23 3 роки тому +6

    You're a legend. Keep it up!

  • @zeryez6347
    @zeryez6347 4 роки тому

    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

  • @olepetersen4460
    @olepetersen4460 3 роки тому

    Many thanks for your comprehensive tutorials. Really good!

  • @alexanderfitterling
    @alexanderfitterling 3 роки тому

    your courses are awesome!! keep going!

  • @ZiyanJunaideen
    @ZiyanJunaideen 3 роки тому

    Love your videos... ❤️
    Very detailed, no BS!

  • @judy8821
    @judy8821 4 роки тому

    Wonderful! I always learn something new thanks to you.

  • @ordozgoite
    @ordozgoite 2 роки тому

    It helped me a lot!

  • @ebeytech
    @ebeytech 4 роки тому

    Amazing tutorials! Thanks for all your efforts in giving excellent examples.

  • @onecarwood
    @onecarwood 4 роки тому +2

    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.

  • @juanmanuelgentili2152
    @juanmanuelgentili2152 3 роки тому

    Amazing. Super complete!

  • @insertacoin738
    @insertacoin738 3 роки тому

    just majestic

  • @mig12394
    @mig12394 4 роки тому

    Always very interesting, a lot of new things to learn

  • @Saltyyydog
    @Saltyyydog 3 роки тому

    You are awesome ! Thank you very much for this video 😃

  • @thephantom1237
    @thephantom1237 3 роки тому

    thanks a lot for the video.

  • @velomehr6845
    @velomehr6845 3 роки тому

    such an informative lesson - thank you very much!

  • @FF7824
    @FF7824 4 роки тому

    Fantastic job. Thank you!!

  • @BhavaniNainala
    @BhavaniNainala 2 роки тому +1

    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

  • @StefanSteinbauer
    @StefanSteinbauer 4 роки тому

    Thank you Paul. awesome stuff

  • @yazidali7071
    @yazidali7071 3 роки тому

    Amazing video.....

  • @d7writes
    @d7writes 4 роки тому

    Fantastic video! 👍

  • @johnheaney3349
    @johnheaney3349 3 роки тому +1

    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.

  • @juanjnino
    @juanjnino 4 роки тому

    Thanks! Learned a ton!

  • @antiasva
    @antiasva 4 роки тому +1

    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.

  • @ElGualdo
    @ElGualdo 3 роки тому

    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

  • @yasenivanov6127
    @yasenivanov6127 4 роки тому

    Just perfect! Congratulations!

  • @luisgomezreus732
    @luisgomezreus732 4 роки тому

    Es un vídeo fantástico!!! Muchas gracias Paul

  • @amielterence
    @amielterence 3 роки тому

    Bless you Sir.

  • @RobertBMenke
    @RobertBMenke 4 роки тому

    Great video!

  • @maverickchan9552
    @maverickchan9552 4 роки тому

    always helpful !!!

  • @Min-YiChen
    @Min-YiChen 3 роки тому

    Thank you so much , appreciate!

  • @AleMohamad
    @AleMohamad 4 роки тому +1

    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!

  • @burroughsjd
    @burroughsjd 4 роки тому

    Awesome stuff!

  • @ZhengCheng
    @ZhengCheng 3 роки тому

    Thank you!

  • @xinth23
    @xinth23 4 роки тому

    Paul, I love your videos. Can you also please do a video on how to type as fast as you? :-)

    • @twostraws
      @twostraws  4 роки тому +3

      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 😅

  • @asigivati1382
    @asigivati1382 3 роки тому

    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?

  • @apptouchtechnologies3722
    @apptouchtechnologies3722 2 роки тому

    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.

  • @docendodisco-it
    @docendodisco-it 4 роки тому

    It is a very good video but there is an interesting point which is not addressed I think. How do we programmatically go back?

  • @celmarostaff
    @celmarostaff 4 роки тому

    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.

  • @drummerjim
    @drummerjim 4 роки тому

    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?

  • @DavidNitzscheBell
    @DavidNitzscheBell 3 роки тому

    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.

  • @developer-juice-Khailenno
    @developer-juice-Khailenno 3 роки тому

    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.

  • @soheilpakgohar6630
    @soheilpakgohar6630 4 роки тому

    you are the best .....

  • @abrahamghaemi8895
    @abrahamghaemi8895 4 роки тому

    very helpfull tnx bro

  • @TheYusuf10
    @TheYusuf10 4 роки тому

    The MAN...

  • @hsksearch3
    @hsksearch3 3 роки тому

    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

  • @dewigesrek5651
    @dewigesrek5651 3 роки тому

    Is it possible to remove the default top navigation space ? Thanks

  • @jeffsherin9564
    @jeffsherin9564 7 місяців тому

    NavigationLink with isActive is deprecated now. Is there an updated video?

  • @barche75
    @barche75 4 роки тому

    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?

  • @jason_bourne17
    @jason_bourne17 3 роки тому

    Hello sir!
    how navigate back to a specific view?
    A->B->C->D->B

  • @paulorodrigues8475
    @paulorodrigues8475 3 роки тому

    How can I navigate by click on the image from example?

  • @crisag.2698
    @crisag.2698 4 роки тому

    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.

    • @tahmidazam639
      @tahmidazam639 4 роки тому

      Use a Zstack with the colour and the navigation view

  • @jorool1988
    @jorool1988 3 роки тому

    Great video, man! I still hate swift though. hahahahaha

  • @bibinjacob123
    @bibinjacob123 4 роки тому

    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.

  • @jwkranenburg
    @jwkranenburg 4 роки тому

    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?

  • @cloudlee4231
    @cloudlee4231 4 роки тому

    Wow, thank you very much. How many hours should I do coding for, to write code without any googling like you?

  • @brucknerdevilliers
    @brucknerdevilliers 3 роки тому

    Paul, With Xcode12 beta, AppDelegate is no longer available, so I am confused how we tackle to the navigation bar attributes.

  • @blueducktrading
    @blueducktrading 3 роки тому

    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.

    • @twostraws
      @twostraws  3 роки тому +1

      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 👍

    • @blueducktrading
      @blueducktrading 3 роки тому

      @@twostraws Awesome! Great content really enjoying it.

  • @thomasipad7719
    @thomasipad7719 3 роки тому

    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

  • @zaurmahmudov1438
    @zaurmahmudov1438 4 роки тому

    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.

  • @jigneshstratecore1336
    @jigneshstratecore1336 3 роки тому

    how can we hide back button in view

  • @yours.trustworthy
    @yours.trustworthy 3 роки тому

    After 25:15 I understood, its not my cup of tea. Thanks

  • @sumupitchayan
    @sumupitchayan 4 роки тому

    Is there a reason you use the XCode Simulator instead of the live preview in Canvas?

  • @calebhansen9316
    @calebhansen9316 4 роки тому

    Is there a quicker way to embed in NavigationView like there is with embed in HStack, etc.?

  • @rabinswalterraj2263
    @rabinswalterraj2263 4 роки тому

    how to access Observed object inside observable class

  • @petersuvara
    @petersuvara 4 роки тому

    Hey Paul, do you have an update for the Swift UI 2 new NavigationTitle and associated styling, NavigationBarTitle has been deprecated.

  • @udesai2011
    @udesai2011 3 роки тому

    Is transcript for the video available.

  • @b0red7
    @b0red7 4 роки тому

    hey ... random question ... how can you make a clone of notion or taskade.com ?

  • @Ferd414
    @Ferd414 3 місяці тому

    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.

    • @twostraws
      @twostraws  3 місяці тому

      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.”

    • @Ferd414
      @Ferd414 3 місяці тому

      @@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.

  • @jcj3582
    @jcj3582 4 роки тому

    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?

  • @sonjack7261
    @sonjack7261 3 роки тому

    How is "isActive" work ? I dont konw

  • @MarkVaughnLive
    @MarkVaughnLive Рік тому

    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.

  • @ecptavares
    @ecptavares 4 роки тому

    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.

  • @somersmatthews2749
    @somersmatthews2749 3 роки тому

    why do swift youtubers never show link to source code in description?

  • @iphoneultra
    @iphoneultra 4 роки тому

    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 !!

  • @fioktistwerner6706
    @fioktistwerner6706 4 роки тому

    TextEditor(text: $text)
    does not work in ScrollView !

  • @sknown
    @sknown 3 роки тому

    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

  • @ZoeSummers1701A
    @ZoeSummers1701A 4 роки тому

    Why does “$selection work?

    • @syedmoamberraza1490
      @syedmoamberraza1490 4 роки тому

      when we use two way bind we have to use that $ sign with variable.

  • @kell7689
    @kell7689 3 роки тому +1

    NavigationView is feeling very limiting...

  • @muazhassan_
    @muazhassan_ 4 роки тому

    Do same for UIKIT (swift) also and thanks for the content xd

  • @mrcodmansfriend
    @mrcodmansfriend 4 роки тому

    boom.

  • @ZoeSummers1701A
    @ZoeSummers1701A 3 роки тому

    SwiftUI syntax, layout and the idiosyncrasies are pathetic. I can’t believe Apple is behind this abomination.

  • @MatthewCoxTheReal
    @MatthewCoxTheReal 4 роки тому

    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.

  • @davehall6001
    @davehall6001 2 роки тому

    AppDelegate.swift is no long created by XCode. Have to add the UINavigationBarAppearance codes in the "mainApp' file using init() {...}

  • @dwpalme2670
    @dwpalme2670 10 днів тому

    You never showed how to automatically move to a new view.