The Complete Guide to NavigationView in SwiftUI

Поделиться
HTML-код
  • Опубликовано: 8 сен 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

  • @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?

  • @yixe2253
    @yixe2253 4 года назад +13

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

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

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

  • @dennissargent7733
    @dennissargent7733 4 года назад +5

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

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

  • @HuyLe-hn9le
    @HuyLe-hn9le 2 года назад

    You are incredible. Thank you sir ,we love you

  • @ZoomerAction
    @ZoomerAction 2 года назад

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

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

  • @JasonMitchellAZ
    @JasonMitchellAZ 4 года назад +2

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

  • @eliymim
    @eliymim 3 года назад

    Paul you're the king.

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

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

  • @kingkevin23
    @kingkevin23 3 года назад +6

    You're a legend. Keep it up!

  • @insertacoin738
    @insertacoin738 3 года назад

    just majestic

  • @alexanderfitterling
    @alexanderfitterling 3 года назад

    your courses are awesome!! keep going!

  • @thephantom1237
    @thephantom1237 3 года назад

    thanks a lot for the video.

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

  • @ordozgoite
    @ordozgoite 2 года назад

    It helped me a lot!

  • @ZiyanJunaideen
    @ZiyanJunaideen 3 года назад

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

  • @juanmanuelgentili2152
    @juanmanuelgentili2152 3 года назад

    Amazing. Super complete!

  • @ebeytech
    @ebeytech 4 года назад

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

  • @judy8821
    @judy8821 4 года назад

    Wonderful! I always learn something new thanks to you.

  • @velomehr6845
    @velomehr6845 3 года назад

    such an informative lesson - thank you very much!

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

  • @yazidali7071
    @yazidali7071 3 года назад

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

  • @luisgomezreus732
    @luisgomezreus732 4 года назад

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

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

  • @Saltyyydog
    @Saltyyydog 3 года назад

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

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

  • @FF7824
    @FF7824 4 года назад

    Fantastic job. Thank you!!

  • @amielterence
    @amielterence 3 года назад

    Bless you Sir.

  • @StefanSteinbauer
    @StefanSteinbauer 4 года назад

    Thank you Paul. awesome stuff

  • @mig12394
    @mig12394 4 года назад

    Always very interesting, a lot of new things to learn

  • @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?

  • @Min-YiChen
    @Min-YiChen 3 года назад

    Thank you so much , appreciate!

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

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

  • @yasenivanov6127
    @yasenivanov6127 4 года назад

    Just perfect! Congratulations!

  • @juanjnino
    @juanjnino 4 года назад

    Thanks! Learned a ton!

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

  • @d7writes
    @d7writes 4 года назад

    Fantastic video! 👍

  • @jeffsherin9564
    @jeffsherin9564 7 месяцев назад

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

  • @abrahamghaemi8895
    @abrahamghaemi8895 4 года назад

    very helpfull tnx bro

  • @jason_bourne17
    @jason_bourne17 3 года назад

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

  • @dewigesrek5651
    @dewigesrek5651 3 года назад

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

  • @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?

  • @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?

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

  • @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 😅

  • @soheilpakgohar6630
    @soheilpakgohar6630 4 года назад

    you are the best .....

  • @RobertBMenke
    @RobertBMenke 4 года назад

    Great video!

  • @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?

  • @maverickchan9552
    @maverickchan9552 4 года назад

    always helpful !!!

  • @brucknerdevilliers
    @brucknerdevilliers 4 года назад

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

  • @burroughsjd
    @burroughsjd 4 года назад

    Awesome stuff!

  • @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?

  • @calebhansen9316
    @calebhansen9316 4 года назад

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

  • @petersuvara
    @petersuvara 4 года назад

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

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

  • @sumupitchayan
    @sumupitchayan 4 года назад

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

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

  • @udesai2011
    @udesai2011 3 года назад

    Is transcript for the video available.

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

  • @TheYusuf10
    @TheYusuf10 4 года назад

    The MAN...

  • @cloudlee4231
    @cloudlee4231 4 года назад

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

  • @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?

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

  • @jigneshstratecore1336
    @jigneshstratecore1336 3 года назад

    how can we hide back button in view

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

  • @rabinswalterraj2263
    @rabinswalterraj2263 4 года назад

    how to access Observed object inside observable class

  • @b0red7
    @b0red7 4 года назад

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

  • @somersmatthews2749
    @somersmatthews2749 3 года назад

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

  • @sonjack7261
    @sonjack7261 3 года назад

    How is "isActive" work ? I dont konw

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

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

  • @fioktistwerner6706
    @fioktistwerner6706 4 года назад

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

  • @yours.trustworthy
    @yours.trustworthy 3 года назад

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

  • @muazhassan_
    @muazhassan_ 4 года назад

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

  • @ZoeSummers1701A
    @ZoeSummers1701A 4 года назад

    Why does “$selection work?

    • @syedmoamberraza1490
      @syedmoamberraza1490 4 года назад

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

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

  • @sknown
    @sknown 4 года назад

    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

  • @Ferd414
    @Ferd414 4 месяца назад

    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  4 месяца назад

      All the old iOS 15 and even iOS 13 videos remain on RUclips, 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 4 месяца назад

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

  • @kell7689
    @kell7689 3 года назад +1

    NavigationView is feeling very limiting...

  • @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 27 дней назад

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