How to Use Child ViewControllers (Container Views) in Swift - Programmatic & Storyboard

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 169

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

    Watch Next - iOS Take Home Project - Job Interview Practice - Free Preview - ruclips.net/video/MSIe2y6Fee8/видео.html

  • @lukeroberts3235
    @lukeroberts3235 5 лет назад +17

    Was always worried about child view controllers. Didn’t realise how easy they were! Will definitely use these for my next project. Thanks Sean :)

  • @danluba
    @danluba 4 года назад +3

    I always look for Sean Allen videos first whenever I need those sweet iOS tips.

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

      Happy to help, Dan!

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

      I know right! Haha, the first video I think I saw from him was mapkit

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

    You just clarified both container views and segues for me in under ten minutes. Awesome!

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

      Happy to help, Nate!

  • @patchinator6
    @patchinator6 11 месяцев назад +1

    You're the man, Sean! Thanks for this

    • @seanallen
      @seanallen  11 месяцев назад +1

      My pleasure!

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

    if the viewer listens to the details that are tucked into this video, they'll learn like 1-full-year of Swift programming. the completeness of concepts is appreciated. almost like Sean is reading my mind (and the questions in my mind).

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

      Thanks for the kind words, Anthony!

  • @dimiutube
    @dimiutube 4 года назад +1

    Very clear and easy to understand! Thanks for showing both ways of adding child viewcontrollers as I will need the programmatic way!

    • @seanallen
      @seanallen  4 года назад +1

      Glad it was helpful!

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

    clearly see how you enjoying to teach coding. Thanks Sean.

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

      Thanks for the kinds words, Eric.

  • @theafzalansari01
    @theafzalansari01 5 лет назад +1

    Was searching this topic for next project and here Sean Make a video of it thanx Sean.

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

    You should include "Embedded Segues" into the title, because I wasn't aware those are only Child ViewControllers, but your video helped a lot, thank you. And a much bigger thanks for showing how to do it in code, this is what I needed.

  • @Alana9374
    @Alana9374 4 года назад +1

    Thanks soooo much for sharing CLEARLY unlike a lot of others before you.

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

      Thanks for the kind words, Rob!

  • @kolyalibak725
    @kolyalibak725 4 года назад +4

    Wow! Great video, thank you
    Maybe you could help me, how can I make this slide-up card (from first example)? Thank you)

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

    very nice to see ChildViewController

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

    Thanks. But should we create a UIView as container view and add that childVC into this UIView? As two steps, I see a lot of examples add container view like this. What is different with adding childVC as containerView directly?

  • @smarter2610
    @smarter2610 5 лет назад +1

    Sean do you use or did you use RxSwift? Is it necessarry for junior ios ?? To be honest for me it is really hard to learn it and probably I will resign of it and focus more on basics like mvvm.

    • @seanallen
      @seanallen  5 лет назад

      I've never used it before. But it's not uncommon.

  • @JasonMitchellAZ
    @JasonMitchellAZ 5 лет назад +2

    Great job covering both storyboard and programmatically in one video, Sean

  • @darrengillman4001
    @darrengillman4001 5 лет назад +1

    Nice concise explanation. What vid was the explanation of static properties on (and more importantly does it cover the when/why, as well as the how)?

    • @seanallen
      @seanallen  5 лет назад

      It was 4 or 5 videos ago. But here's the link: ruclips.net/video/s2E5hVxQAZQ/видео.html

    • @seanallen
      @seanallen  5 лет назад

      And yes, I give real examples of when to use it.

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

    Is the slide up controller a card view controller ? Any videos you’d be able to recommenced on it ? Thanks for sharing this vid ; helpful.

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

      In this case, it's just a view.

  • @JunaidKhan-ny8tu
    @JunaidKhan-ny8tu 5 лет назад +3

    What a coincidence!!! I was searching for this topic since last night :) thanks for such awesome content

    • @seanallen
      @seanallen  5 лет назад +2

      I knew you're looking for it. That's why I made it.

    • @JunaidKhan-ny8tu
      @JunaidKhan-ny8tu 5 лет назад +2

      Sean Allen haha thanks super man 😍😍❤️

    • @mracipayam
      @mracipayam 5 лет назад +1

      Sean was listening your phooonnee and looking for content :D

  • @manuhh9340
    @manuhh9340 5 лет назад +2

    Thank you Sean! Nice tutorial!! By the way, what chart library are you using?

    • @seanallen
      @seanallen  5 лет назад +1

      It's a library called "Charts". Google "iOS Charts" and the repo should pop up

    • @manuhh9340
      @manuhh9340 5 лет назад

      @@seanallen Thanks man! I'm using the same one, but your chart looks way cooler :D

  • @iliana_b
    @iliana_b 5 лет назад +1

    excellent video. short and sweet! keep it coming Sean!

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

    Great video! I really enjoy the way you code! very neat :)

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

      Thanks Negar. Happy to hear it 😀

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

    Thanks for this amazing tutorial

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

      You're very welcome!

  • @TheFirzoknadeem1
    @TheFirzoknadeem1 5 лет назад +1

    How did you make that sliding window in your app? Do you have a tutorial on that? I've been trying to make a sliding view on a map view but it is not working for me. The sliding view completely covers the whole map view.

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

    Great video! Question: when/where was the secondChildVC set to green (initially)? Thanks!

  • @johnryles65
    @johnryles65 5 лет назад +6

    Segue enum is brilliant!

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

    I had no idea that this existed, but man I need this so bad in my app. Thank you

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

      Happy to help you discover this 😀

  • @synagridas13
    @synagridas13 5 лет назад +2

    Excellent explanation as always. 1 question: when & why to use child View Controller, instead of just a subview(Ie a child UIView) ? Thank you 🙏

    • @seanallen
      @seanallen  5 лет назад +2

      John Sundell explains that very well at the bottom of his article here. I'm too lazy to type it all out, lol: www.swiftbysundell.com/basics/child-view-controllers/

    • @synagridas13
      @synagridas13 5 лет назад

      Great - thank you! Will read it :)

  • @geoffbaker2554
    @geoffbaker2554 5 лет назад

    Great video, thank you.
    Sean I am struggling with a container view that is embedded and always visible on a macOS app. I can’t pass and display data because it doesn’t ‘load’ again as it’s always visible. Any thoughts or videos that may help?

    • @seanallen
      @seanallen  5 лет назад

      I've never built a macOS app, so I'm not sure I can be of help here. My apologies.

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

    Great video Sean. I have a question, in your introduction you show an app where a child view appear from the bottom, you created that effect changing the bottom constraint value while tapping the child view?

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

      Yes. Thank you for the video but when I see an example in the first part of the video, I would like to see the very same example in the tutorial. I wanted the slide up function, but I spent 10 minutes and there was no explanation about this. Waste of time. You make great videos, but pay attention to this, please...

  • @RussellSivalingam
    @RussellSivalingam 5 лет назад +1

    Sean, as usual, another brilliant tutorial. that Segues enum.. brilliant!!

    • @seanallen
      @seanallen  5 лет назад +1

      Glad you liked it, Russell!

  • @ajinkyasonar
    @ajinkyasonar 4 года назад +1

    Hey Sean, how can we make the container view dynamic. In this video you have provided an height constraint but what if we need it’s height should be based on the child view controllers content size?

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

      Just add constraints between child vc’ view and it’s sub views in child view controller ,and make sure there are enough constraints in vertical orientation

  • @AntonBrock
    @AntonBrock 4 года назад +1

    I just search best practices for pass data between two or more Vc and I fined it! Ty for video! But I want to know how to do something like your first view ( with graph) if you have video about it pls link it! Ty!

    • @seanallen
      @seanallen  4 года назад +1

      Glad you liked the video! For that chart I used a 3rd party library called "Charts". If you google "iOS Charts library" it should pop up.

    • @AntonBrock
      @AntonBrock 4 года назад +1

      @@seanallen Ty! It's help me

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

    @seanallen can you show another example of how to pass values to a child view container? for example I have a slider in main view and a label in a container view and I want to display the slider value in label that is in container view but the slider is in main view.

  • @pradeepkumar-tm5et
    @pradeepkumar-tm5et 3 года назад

    Hi Sean hope you are doing good. Could you please tell me the api response format how that need to be in order to the data in charts.

  • @w0mblemania
    @w0mblemania 5 лет назад +1

    Good tutorial, Sean. Thanks!
    Question: your charts look very good. Which charting framework are you using? Or Macaw, or rolling your own?

    • @seanallen
      @seanallen  5 лет назад

      This one was built using "Charts". Google iOS Charts, and you should find the repo. It was built before I heard of Macaw.

    • @w0mblemania
      @w0mblemania 5 лет назад +1

      @@seanallen Thanks Sean.

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

    Great video. Two questions 1) what charting library do you use in the first app shown? 2) how do you record your videos? I like that you are in the front with the background the desktop.

    • @seanallen
      @seanallen  4 года назад +1

      Thanks Neil. It's a library called "charts". If you google iOS Chart library, it should be one of the first results. I record my face with a regular camera (with a greenscreen), my voice with a Blue Yeti mic and QuickTime, and I record my screen with QuickTime. Then I edit it all together in Final Cut Pro.

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

      Sean Allen thanks for your reply. Much appreciated, I’ll follow your channel now.

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

      Thanks for the support 😀

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

    Hi, do you have a video on how to make floating panels? :)

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

    Great video! please do tutorial on switching between multiple/different UIViewControllers within single containerView. thanks in advance!

  • @mohammadsayed5645
    @mohammadsayed5645 5 лет назад +1

    You are doing a great job. Keep it up

  • @AliAljoubory
    @AliAljoubory 5 лет назад

    Always great timing with your videos man. Been using childVc's on a project at work through Storyboards, but the 1 thing I was stuck on was being able to control when the childVc was initialised through the segue. It seems that the segue is always performed at viewDidLoad in the parentVc, no matter where else I tried calling performSegue. I basically wanted to initialise the view after making an API call on the parentVc, but that never could work out.
    Is there an actual way to control when the childVc is created or will that always be when the parentVc loads?
    Thanks for the video again man.

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

      Late response, but did you try using childvc’s programmatically? That way you’re able to determine when exactly they are created.

  • @xMhnd
    @xMhnd 5 лет назад +1

    Great work Sean! This was much simpler than what i expected. Was the slide chart made by you or a3rd party library?

    • @seanallen
      @seanallen  5 лет назад +2

      The card was made by me, the chart is a 3rd party library called "charts"

    • @FatmaMohamed-mm6zo
      @FatmaMohamed-mm6zo 4 года назад

      @@seanallen hello, how did you implement the card with that style ?

  • @gakkieNL
    @gakkieNL 5 лет назад +1

    As always a great watch! Thanks and cheers!

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

    Cool! So helpful, thanks

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

    Hey Sean thanks for this video. I was wonder if it's possible that you somehow upload the codes?(for all your tuts from now on...)

  • @Денис-ж3ф5р
    @Денис-ж3ф5р 3 года назад

    good stuff man.

  • @brandonb6175
    @brandonb6175 5 лет назад

    Hey Sean, any SDK recommendations for charting, great video btw!

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

    If you wanna have clean architecture where to store such enum like "Segues"? What folder or so?

  • @Monarch_943
    @Monarch_943 5 лет назад

    Hey Al, I'm trying to create an app with a navigation drawer, basically one parent viewController that has the drawer and handles switching view controllers in the container view. Is this a good approach?

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

    Hey Shawn, is it possible to add constraints to secondChildVC?
    Suppose it has to display some text inside. Every time I try to add a constraint within secondChildVC, xcode yells at em that it cant satisfy all constraints.

  •  5 лет назад +1

    Helpful as always, thanks!

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

    do you think it is best to have segues in a different file?

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

    Hi Sean, good video , nice and straightforward. However, when I load a VC as a child, if that Child VC then programmatically changes the text in a label , I get a found nil while unwrapping an optional. The label is declared as an IBOutlet in the code. Hoping you can help.

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

    @Sean Allen I did it exactly like you in code, and now my child view controllers do not receive any touch events. what could be wrong? child VCs are instantiated from .xibs, but added programmatically

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

    Sean, Thanks a lot. That's brilliant...

  • @BubbleBassBackShots
    @BubbleBassBackShots 5 лет назад +1

    A question Sean (several actually ): Let's say i were to attach a button to initiate a segue from one view controller to another and wanted to pass data as well. If i were to use the override function "prepare", how would it work ? Would the override function execute independently of the button (like you said in the vid), or will it execute after the button is pressed to move to the other view controller. Does the button only act as the "presenter" for the next view controller ? Does the override function keeps on getting called whenever data is changed on the sending view controller?

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

    in your actual application how you managed swipe gestures on child view?

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

    Hi . It is good .please share how to add child view as hamburger menu as coustmized viewcontroller

  • @omarmhaimdat
    @omarmhaimdat 5 лет назад +1

    Always great content, keep up buddy!

  • @TheAhmadReza
    @TheAhmadReza 5 лет назад

    Where should we setup child view subviews!? (within ViewController or SecondChildVC)

  • @jmlp1327
    @jmlp1327 4 года назад +1

    Thanks a lot 🤗🤗🤗

  • @mracipayam
    @mracipayam 5 лет назад +1

    its very clear

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

    So dope!! :)

  • @kelvinfok
    @kelvinfok 5 лет назад +2

    Hi buddy, great tutorial. Will be good if the text is bigger cus I’m viewing from mobile :)

    • @seanallen
      @seanallen  5 лет назад

      Thanks for the feedback. I'll keep it in mind. It's already really big on my screen. Much bigger and the line wrapping on all the code will start to look really bad.

  • @StateMachineJunkie
    @StateMachineJunkie 5 лет назад +1

    What is the advantage of using enum Segues { ... } versus struct Segues { ... } ?

    • @seanallen
      @seanallen  5 лет назад

      It's a minimal difference... and enum can be better because if it's a struct you could initialize an empty one and have a random object out there. Doing something like Colors() will initialize an empty struct. You can't do that with an enum. So an enum is a little better for safety reasons in that example.

    • @roman3249
      @roman3249 5 лет назад

      Segues() not Colors(). Colors() is from another video))))​

  • @jamesb1664
    @jamesb1664 5 лет назад +3

    Can someone tell me the name of the slide up card (that only covers half the screen) at the start of the video? Twitter and instagram have recently implemented the same thing.

    • @anuroopkanayil5724
      @anuroopkanayil5724 5 лет назад

      JB - i am also looking for the bottom slide up card.

    • @jamesb1664
      @jamesb1664 5 лет назад +1

      Anuroop Kanayil twitter.com/lukew/status/1016388934933217282?s=21

    • @jamesb1664
      @jamesb1664 5 лет назад +1

      Anuroop Kanayil you may find this thread interesting

    • @anuroopkanayil5724
      @anuroopkanayil5724 5 лет назад

      Thanks 👌🏻

    • @jamesb1664
      @jamesb1664 5 лет назад

      Anuroop Kanayil I ended up using the framework Material.io and using their version of a bottom sheet - it works very well

  • @DimitrisTheo
    @DimitrisTheo 5 лет назад +1

    Nice Sean 🤙🏻

    • @seanallen
      @seanallen  5 лет назад +1

      Glad you liked it!

    • @DimitrisTheo
      @DimitrisTheo 5 лет назад

      Sean Allen Doing both is way better for understanding

    • @seanallen
      @seanallen  5 лет назад +1

      I agree. Sometimes doing both in the same video can be too long tho. This time it was quick.

  • @TranHoang-up9mb
    @TranHoang-up9mb 5 лет назад +5

    We use container view to avoid “massive view controller”, right ?

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

    so, when we use self.addChild or self.present?

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

    How do you re-use child view controller in a different parent view controller?

  • @baralr-jay7729
    @baralr-jay7729 Год назад +1

    Thanks broooooooo

  • @guruitcompany
    @guruitcompany 5 лет назад +1

    Wow! 🤔👍👍Thanks!

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

    can we have some flutter videos. How to do iOS apps/ widgets in flutter?

  • @tak68tak
    @tak68tak 4 года назад +1

    Cool!

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

    Hello Sean please how to do the bottom menu card

    • @seanallen
      @seanallen  4 года назад +1

      coming soon

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

      @@seanallen Did you ever end up doing this tutorial?

  • @brunoandrade8492
    @brunoandrade8492 5 лет назад +1

    How can I make these dashed lines connecting the meteors/planets using SpriteKit?

    • @seanallen
      @seanallen  5 лет назад

      In the case of this app... it’s an image. However you could draw a UIBezierPath with a gradient full I guess.

  • @esc4p3EP
    @esc4p3EP 5 лет назад

    Terbaik lah botak!

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

    So child view controllers cant share a class with the main view controller.

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

    Please any one can tell me how to create expandable ViewController on parent ViewController like he showed chart ViewController on parent ViewController in start of the video.

  • @Денис-ж3ф5р
    @Денис-ж3ф5р 2 года назад

    Who are those people using storyboards

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

    You didn't show how to do the reverse. Get data from child to parent.

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

    Can someone help me to change my Xcode color to red as seen in this video?

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

      It's in your General Mac settings, not Xcode. You can choose your accent color.

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

      @@seanallen Thank you so much. I thought it was an Xcode specific setting.

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

    8:55 - Ukraine 🇺🇦

  • @vamsi3877
    @vamsi3877 5 лет назад

    When to remove child ?

    • @freeme6111
      @freeme6111 5 лет назад +2

      when it's 18 yrs old

    • @vamsi3877
      @vamsi3877 5 лет назад

      @@freeme6111 😁

    • @saj5935
      @saj5935 5 лет назад

      @@freeme6111 😂

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

    So I'm taking someone's iOS Dev course (seanallen.teachable.com/) and the instructor over there sets his constraints with an array to avoid manually tacking on the isActive at the end of each. Any benefit to the more manual way shown here or is it really just down to preference?

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

      This video using .isActive = true was before I knew that using the array for NSLayoutConstraints.activate is more efficient.

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

      @@seanallen Gotcha. It's helpful to see not only the various ways you can accomplish the same task but also to see how your preferences change through these videos and in your course. It points to the fact that while optimization is important, what's MORE important is using the tools you have to solve the problem to yield the desired result.
      Love the videos on RUclips for these one-off topics, but your course (65% through so far) is incredibly thorough, provides the 'why' behind a lot of stuff 'cut and paste coders' know to do but can't explain why, and definitely worthwhile for anyone interested in the field.

    • @seanallen
      @seanallen  4 года назад +1

      Thanks for the kind words on the course. Hopefully, as an engineer, you're constantly evolving and improving so your thoughts on certain topics and implementations will change over time.

  • @k3mp3r111
    @k3mp3r111 5 лет назад +6

    God bless Ukraine 🇺🇦
    (VC at the end of video lol)

  • @Денис-ж3ф5р
    @Денис-ж3ф5р 3 года назад

    the more I learn, the more I realize I know nothing, period

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

    Ukraine

  • @ЯрославГрицунь
    @ЯрославГрицунь 5 лет назад

    maybe coding isn't THAT scary after all...

  • @djryanashton
    @djryanashton Год назад

    I like your videos but this doesn't really match with the modal presentation example in the beginning. I'm wanting to present a 2nd VC modally with a few custom settings (such as the MainVC not shrinking in size) and also present only a 1/4 way up the screen. I'm sure you have a video that I could learn from ;)
    I found this (ruclips.net/video/qiOKO8ta1n4/видео.html) which addresses both issues. Thanks Sean.

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

    DOOD!