NavigationStack - SwiftUI Programmatic Navigation - iOS 16

Sdílet
Vložit
  • čas přidán 19. 06. 2024
  • Head to squarespace.com/seanallen to save 10% off your first purchase of a website or domain using code SEANALLEN.
    I explain how to use the new NavigationStack to navigate between views in SwiftUI. You will learn the fundamentals of NavigationStack and how to navigate programmatically in SwiftUI using values (data) and not views.
    iOS Developer Courses
    seanallen.teachable.com/
    Twitter:
    / seanallen_dev
    Hired.com:
    hired.com/x/1n01g
    Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):
    Paul Hudson's Hacking With Swift:
    gumroad.com/a/762098803
    Donny Wals - Combine:
    gumroad.com/a/909014131
    Mark Moeyken’s SwiftUI Books:
    www.bigmountainstudio.com/swiftui-views-book/fzc51
    Objc.io Books (Thinking in SwiftUI & Advanced Swift):
    gumroad.com/a/656585843
    Ray Wenderlich Books:
    store.raywenderlich.com/a/208...
    #swift #softwaredeveloper #iosdeveloper
    Timestamps:
    0:00 - What is a NavigationStack
    0:23 - Start Project Review
    1:09 - NavigationStack Fundamentals
    5:09 - Fundamentals Review
    5:24 - Navigating w/ Different Types
    9:26 - Custom Programmatic Navigation
    12:09 - Manipulating NavigationPath Array
    13:12 - Custom Navigation w/ Multiple Data Types
  • Věda a technologie

Komentáře • 93

  • @IamTheGreatCornholioo
    @IamTheGreatCornholioo Před měsícem +7

    Finally someone who explains how to pass data to the view instead of just creating a simple item list

  • @csmac3144a
    @csmac3144a Před rokem +37

    Sean you deserve every bit of success you've achieved. You're a talented communicator, and it's obvious you put an enormous amount of work into each piece of content to maintain a high level of quality and consistency. Keep it up!

  • @ArchangelMichael94
    @ArchangelMichael94 Před 4 dny

    I can't remember the last time I had to slow the playback speed of a video to be able to process it 😅 Loved the vid, jam-packed with good stuff

  • @ilijamihajlovic7467
    @ilijamihajlovic7467 Před rokem +2

    Thanks Sean, I was looking for hours to debug my project. Your video and how you explain stuff helped a lot. Since day one you rock!

  • @ianrickey208
    @ianrickey208 Před rokem +1

    Love your content and instruction. I am a Swift n00b and play your vids at 75% playback speed to follow along. Thanks for it all and when I get through your tutorials I'll subscribe to your courses. At 75% playback speed.

  • @adriangutierrez9812
    @adriangutierrez9812 Před rokem

    Thank you very much for this! You were super easy to follow. Just subscribed. Can't wait to see more you have. Thanks again.

  • @alieldeeb1935
    @alieldeeb1935 Před rokem +12

    Awesome video, thanks for all the work you put into building the next generation of developers!

  • @timotejmatlak4625
    @timotejmatlak4625 Před 3 měsíci +1

    Sean, I really appreciate your work, you can explain complex things in the simplest way ever. Love it...

    • @seanallen
      @seanallen  Před 3 měsíci

      Thanks for the kind words :)

  • @laurentbennis
    @laurentbennis Před 10 měsíci

    This is by far the best tutorial on that subject thank you :)

  • @dhavalnena7386
    @dhavalnena7386 Před rokem +1

    Great tutorial so far!! Glad to see how you managed different types of navigations with different types. Thank you!

  • @ThePossibilityGuy
    @ThePossibilityGuy Před rokem

    Thanks Sean it was clear ❤

  • @krishnavivek9254
    @krishnavivek9254 Před 9 měsíci

    Sean, Great video to fellow developers.

  • @markaurelius61
    @markaurelius61 Před rokem +6

    That was good, clear and helpful. All the view popping up in navigationDestination were in the same View struct though. How does it work when you have different structs? How do you pass the NavigationPath around?

  • @Dragonboh1
    @Dragonboh1 Před rokem

    Keep doing what you doing, man!

  • @paulikhane
    @paulikhane Před rokem

    I like your teaching style

  • @daniel.iosdev
    @daniel.iosdev Před rokem +1

    Amazing as always. Thank you Sean!

  • @nicolaiharbo2201
    @nicolaiharbo2201 Před rokem +1

    Love your videos man! Easily explained and well made :)) Thanks

  • @ulasina
    @ulasina Před rokem

    Very good and fast tutorial.

  • @jaylensmith6308
    @jaylensmith6308 Před rokem +1

    This was a good tutorial to understanding navigation stack. I never knew about the possibilities of using it with data compared to using navigation links

    • @seanallen
      @seanallen  Před rokem

      Yes, it opens up A LOT more possibilities.

  • @nileshjdarji
    @nileshjdarji Před 11 měsíci +1

    This is such a nice tutorial. Thank you Sean.

    • @seanallen
      @seanallen  Před 11 měsíci

      Glad you liked it, Nilesh.

  • @KFrench1123
    @KFrench1123 Před rokem

    Thanks, Sean 👍👍

  • @burakcankurtarr2751
    @burakcankurtarr2751 Před rokem +1

    Amazing tutorial, thanks man!

  • @miguelgonzalez3329
    @miguelgonzalez3329 Před rokem +1

    You are amazing Sean

  • @marinadsf2248
    @marinadsf2248 Před rokem

    Hi Sean, thx for your video, you save my time :) Have you some video to customize NavigationBar ? :)

  • @heenaberiya2669
    @heenaberiya2669 Před 7 měsíci +1

    great tutorial. But what would be best for login and logout functionality if we have auto login option till token expired?

  • @Deadpool25mm
    @Deadpool25mm Před rokem

    Thanks!

  • @bonifacy9511
    @bonifacy9511 Před rokem

    @Sean Allen, great tutorial. Thank you. One question: How to add a custom back button? I would like to get rid of "< Back" in favor of "

  • @cristopherescorcia3276
    @cristopherescorcia3276 Před rokem +4

    Hey Sean great video, I was checking the NavigationStack recently and what I did to have acces to the path in every view is to pass that path via the enviromentObject and put the modifier after the NavigationStack so every view inside the Stack had access to the path and can modified it, for that demo it worked for me

    • @seanallen
      @seanallen  Před rokem +1

      Yes, there are a few different ways you can architect your app so you can have access to this path on different screens. I love the flexibility of this!

    • @rachitsharma8829
      @rachitsharma8829 Před rokem

      Hi Sean, it is very good content.
      I have an questions, how to manage click on different sections like 20 or 40 sections then how can we manage childs wirh click

  • @eduardofulgencio741
    @eduardofulgencio741 Před 5 měsíci +1

    Muy bueno este video. Mil gracias.

  • @JustinHold
    @JustinHold Před rokem

    Great video! I was wondering if it's possible to use .navigationDestination to jump to different Views like you can in TabView?

  • @JemmaGuaney
    @JemmaGuaney Před měsícem

    3:06 : You need to enable a click effect so that user can visually see your mouse clicking.

  • @stelluspereira
    @stelluspereira Před 2 měsíci

    excellent content, but could not find the section collapsible icon , I tried adding
    .listStyle(.sidebar) , would be nice to have collapsible chevron icon

  • @HarendraSharmaGwl
    @HarendraSharmaGwl Před rokem +1

    very much helpful.

  • @cest102
    @cest102 Před rokem +4

    Nice tutorial. Just what I needed. For popping to the root view we can just do path.removeAll() or path = [ ], rather than computing the count I think - slightly safer if it works.

    • @MiaYu
      @MiaYu Před 8 měsíci

      can use path = .init() , not path.removeAll() nor path.removeLast()

    • @GS-XV
      @GS-XV Před 21 dnem

      @@MiaYu If you just wanted to be as compact as possible, that would be path = [ ]
      But path.removeAll() makes the clearest code, because you're indicating what you really want to do - you want to empty the Array.

  • @mahinur_rahman
    @mahinur_rahman Před 10 měsíci

    you are awesome

  • @muradjam
    @muradjam Před 8 měsíci

    Cool video thank you for you effort. However, is it possible to animate “pop to root” ?

  • @Fddiferd
    @Fddiferd Před 2 měsíci

    What do you do if you want to navigate to a settings page which doesn’t necessarily take a data object. Also when dealing with environment objects to you need to inject these into the navigation link?

  • @AmmarSMitoori
    @AmmarSMitoori Před 6 měsíci

    Thanks allot, but when using NavigaationPath how can we add a bunch of views to the path in one go ?

  • @tariqAlmazyad
    @tariqAlmazyad Před rokem

    Beautiful explanation .
    I am still looking for a way to see if I could still use NavigationLink(isActive) with this new API .

    • @seanallen
      @seanallen  Před rokem

      I haven't experimented with that yet.

  • @crocodiluQ2
    @crocodiluQ2 Před 4 měsíci

    what should one do if I want to use this for simpler cases, not lists.. Like I have a button, no data, and I just want to open another screen.

  • @aqibos
    @aqibos Před rokem

    What if the next view isn't related to data, but rather an action? For example, a user logging in. Do I have to create a Hashable struct/object anyways?

  • @rillieux1792
    @rillieux1792 Před rokem +1

    Just found this video - great stuff, and answered a ton of questions. Thanks! Of course, I'm left with the question - how does this work in a NavigationSplitView? I cannot for the life of me figure out where to put the .navigationDestination in a SplitView or if it's even possible to do so in one. Any tips for that?

    • @seanallen
      @seanallen  Před rokem

      Glad you enjoyed it! I haven't worked with this in a SplitView yet, so I can't be of much help here unfortunately.

  • @cashjpgs
    @cashjpgs Před rokem +3

    oh they're cookin now huh

  • @Kush_Daddy
    @Kush_Daddy Před rokem

    Is there a way to use this navigationstack to automatically navigate to your next view? It seems like now when you want to navigate, you have to create a physical button or link to press and begin navigating to the next screen. However, you used to be able to use the navigation links isActive parameter and create an empty view ao that when the condition is met, you can automatically navigate without pressing anything Such as after a api call.

  • @mahinur_rahman
    @mahinur_rahman Před 10 měsíci

    is navigationstack or programatic only for list?

  • @grudev
    @grudev Před rokem

    Awesome video and explanation as always, but i more and more ask myself one question: Are this pyramid of doom style of code really the new paradygm? Why people see this better or more beautiful than imperative style of code???

    • @seanallen
      @seanallen  Před rokem

      The pyramid of doom in when the code is yet to be refactored. Once you refactor your views into components, the look of SwiftUI code becomes clean.

  • @meiowalot7570
    @meiowalot7570 Před rokem

    I have dabbled in this stuff for a while and get so confused. Push/pop? Segue? Programmatically and/or wires up in the storyboards?

    • @seanallen
      @seanallen  Před rokem

      I can see how that could be. There are many ways to do things. Apple has been in a transition over the last few years with Swift and SwiftUI - so it can be confusing.

  • @omarelsayed6241
    @omarelsayed6241 Před rokem

    I am learning iOS developing (beginner), Should I learn the navigation view first and focus on that, then see the lates updates and understand it ?

    • @omarelsayed6241
      @omarelsayed6241 Před rokem

      and does this means that I shouldn't use navigationView anymore?

  • @zeroh_chill2966
    @zeroh_chill2966 Před 4 měsíci

    A year behind, but does anyone know why path.append doesn’t do anything for any of the 3 buttons? Maybe the path.append is no longer the correct method to use in SwiftUI?

  • @homeoffice3524
    @homeoffice3524 Před rokem

    I have a one question. If you know SwiftUI in decent level. Different views,multi screen designs and animations but that’s it. You don’t know swift backend part and networking. If it’s possible to get ui(front end) junior job?

    • @seanallen
      @seanallen  Před rokem

      It's possible... but an iOS job where you ONLY do front end UI work is pretty rare. I've only heard of that at the larger FAANG companies... but it would be pretty tough to get hired at one of those places without knowing the "programming" side of things. Almost all iOS jobs will require more than just UI work.

  • @sarthakshrivastava5596

    Somehow my entire section became a navigation link as a whole and now it goes through every platform before going back to the Gaming section
    Looking to debug this rn

  • @saeedul
    @saeedul Před rokem

    Bro give me advice. I am a student and I am starting new career in development area So I like tow technology Backend or App development which one is good. I mean which one For deeply learning and high learning Please give me advice . Thanks:) Your videos so good.

  • @sadiq4906
    @sadiq4906 Před 2 měsíci

    Why don't you do simply like path = []? to pop to home?

    • @Fddiferd
      @Fddiferd Před 2 měsíci

      I was wondering that to

  • @ConernicusRex
    @ConernicusRex Před 9 měsíci

    I really hate navigation stack and wish they'd make it easier to dynamically display views like it was in UIKit. Navigation stacks make otherwise really nice iOS apps look like windows software.

  • @dmitriyobidin6049
    @dmitriyobidin6049 Před 12 hodinami

    The only problem is - it's only available in iOS 16...

  • @zenithacademy4588
    @zenithacademy4588 Před rokem

    Cannot find 'navigationstack' in scope, please help

    • @seanallen
      @seanallen  Před rokem +3

      NavigationStack requires iOS 16. Make sure the minimum target on your project is iOS 16

  • @danstoian7721
    @danstoian7721 Před rokem

    The fact that NavigationPath needs be type erased, in Swift 5.7, is kind of disappointing to be honest.

    • @seanallen
      @seanallen  Před rokem +2

      Hopefully that can be improved upon in future updates. SwiftUI is a work in progress.

  • @DavidShaw-dc4re
    @DavidShaw-dc4re Před 11 měsíci +1

    I don't understand this concept at all. It makes no sense to me. I am used to clicking a link or button and calling up a new page. Why isn't it possible to have an action linked to a button or screen object that loads a view controller that displays the defined screen objects for rendering and attach events to the objects to drive functionality.

    • @iLoveAppl3947
      @iLoveAppl3947 Před 3 měsíci +1

      Maybe because this is SwiftUI and it's different from UiKit ? Get used to it and stop crying

  • @ailo5026
    @ailo5026 Před rokem

    Hi Sean I really find your videos very helpful! I appreciate it! I was wondering in Xcode in the interface builder storyboard I was trying to make a tic-tac-toe game. In an action I wanted when the user presses a button an X appears at a certain font size. I have looked for a long time around the internet and still couldn't find anything. I will be forever grateful if you could help me 😁.
    @IBAction func testX(_ sender: UIButton) {
    sender.titleLabel?.font = [UIFont withSize(75.0)];
    }
    I tried this it doesn't work.

  • @0542073956
    @0542073956 Před 9 měsíci +1

    great video mate!

  • @AndrewDChristie
    @AndrewDChristie Před 5 měsíci +1

    Thanks!

    • @seanallen
      @seanallen  Před 5 měsíci

      Wow, thanks Andrew. I appreciate the generosity!