Use UIViewRepresentable to convert UIKit views to SwiftUI | Advanced Learning #13

  Рет қаралды 18,872

Swiftful Thinking

Swiftful Thinking

2 жыл бұрын

In this video, we will learn how to convert views from UIKit into SwiftUI. As I've mentioned before, I definitely recommend using native SwiftUI components whenever possible because they are stable and much easier to work with. However, not all SwiftUI components are highly customizable and there are occasional situations where we might want to convert something from UIKit and use it in our SwiftUI application. As you'll see, putting UIKit elements onto the screen in SwiftUI is actually pretty easy. The hard part, which we will also cover, is learning how to communicate the data flow from SwiftUI to UIKit and vice versa, from UIKit back to SwiftUI.
Next video: • Use UIViewControllerRe...
Last video: • Create a custom naviga...
🤙 WELCOME BACK 🤙
WEBSITE: www.swiftful-thinking.com
DISCORD: / discord
GITHUB: github.com/SwiftfulThinking/
SAY THANKS: www.buymeacoffee.com/nicksarno

Пікірлер: 33
@noamif
@noamif 2 жыл бұрын
Hey man, I've been working with UIKit for the past 18 months and need to learn swiftUI for a new job ,and your videos are great for people that know swift but and new to swift ui. really clear and and very good examples, make me understand things that other teachers didn't explain very well. Keep it up!
@ncba
@ncba 2 жыл бұрын
UIKit works so flawlessly (I started on SwiftUI and use it when need be). I hope thats where SwiftUI grows to
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
SwiftUI adoption is on the rise don't worry 🥳
@BruceCichowlas
@BruceCichowlas 2 жыл бұрын
That was really excellent and just what I needed today!
@cinquain0
@cinquain0 2 жыл бұрын
Truly wonderful video. I’ve used viewrepresentables before but still learned something new. Great job Nick
@kasunjayasekara3052
@kasunjayasekara3052 2 жыл бұрын
Thank you very much it's an amazing explanation.
@AADITYAAA
@AADITYAAA 2 жыл бұрын
this is so helpful thanks a ton!!
@JZ-xc8hu
@JZ-xc8hu Жыл бұрын
thank you , i can easily understand in a short time
@tchendoh
@tchendoh 11 ай бұрын
Thanks a lot! Kind of scary at first but it all makes sense.
@rungxanh2901
@rungxanh2901 8 ай бұрын
What a gem!
@GGGGGG-qj2un
@GGGGGG-qj2un Жыл бұрын
I'm impressed. I'm too old for this stuff. I wish I were young. There was no OS when I was a teen.
@marclutke1900
@marclutke1900 2 жыл бұрын
Now my understanding is much better than before. Maybe it helps me to solve my Custom Annotation problem. 😅
@paulancajima
@paulancajima 2 жыл бұрын
Thank you
@AdjieSatryo
@AdjieSatryo Жыл бұрын
Thank you for the explanation nick! Does it also work with the UIKit view gesture, for example pinch zoom
@shekharsaini9069
@shekharsaini9069 Жыл бұрын
Thanks 👍👍👍🙏👍🙏
@mackmelodeeofficial
@mackmelodeeofficial 9 ай бұрын
Hi Nick and firstly thanks for all that work on your channel!! May it be, that the last marker at 24:03 in 10/06/2023 now is deprecated? It says to me "Value of type 'some View' has no member 'updatePlaceholder'". All best ✌ Edit: no, it still works (I just messed up the modifier-hierachy)
@KimbrellBrad
@KimbrellBrad 2 жыл бұрын
Very nice Nick! I have a need for a grid entry within a ScrollView in SwiftUI. Is that something that I can do in this same manner? Seems that getting all of the data back into SwiftUI would be a challenge (for me LOL.) I tried building a grid using a LazyVGrid with gridColumn widths assigned and it works but when I tried to allow data entry directly into the grid using a TextField in SwiftUI it does not behave very well. I have dates, Doubles, & Currency to be entered and the rows / columns become too large on a phone-sized screen. I can fill the grid with data from the users DB but data entry is clunky. Is this how you would approach a problem like this? If so, any hints? Thanks so much for your great tutorials! I have followed every video you have published. So well done!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Hey Brad! From the sounds of this, I don't think you would need UIViewRepresentable. I would probably use a LazyVGrid inside a ScrollView. There have been some bugs with the LazyVGrid so I'm not sure if what you're running into is a bug or maybe something is configured to update correctly (usually the case for me haha). If you really think it's a LazyVGrid bug, then you can make you're own grid using a VStack with HStacks inside?
@ShooMPozitiV
@ShooMPozitiV 2 жыл бұрын
If youtube let me like this video 1000 times - I've did it )
@istalzer2
@istalzer2 Жыл бұрын
Hi Nick, Love all your videos. New to Swift, pretty comfortable with SwiftUI (thanks to you :) ). A friend has an app written 100% UIKit, would love to help make some updates with SwiftUI but haven't figured out how to make my views work in his existing app. Example replacing the nav bar with a custom one like you showed us in a previous video. Have you done a video or have suggestions on how migrate a UIKit project to SwiftUI? Or how to integrate the two? Would be great to keep the app alive, and integrate tab by tab, instead of writing everything from scratch 100% SwiftUI. Any ideas are much appreciated. Thank you!! And thank you for these videos!! P.S. Are you available for hire? Contract work?
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
I’ve done some migrations before. My recommendation is to work backwards, with the root views and tab bar to switch to SwiftUI last. I would start with swapping out the easy screens with the least dependencies. It’s hard to give advice here without seeing the architecture.
@cdhello4413
@cdhello4413 2 жыл бұрын
Great video!! I have a xib in UIKit with dynamic size (need to hide some content on the basis of some logic). How to make sure that in SwiftUI the frame size is updated on the basis of the content of this xib ?
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
You can set the frame of the UIKit component within the makeUIView function, and you can also set the SwiftUI frame with a regular .frame() modifier!
@tmjromao
@tmjromao 2 жыл бұрын
KUDOS! thank you very much for sharing your knowledge. Do you intent to explain how to use "Combine" lib? much appreciate. All the best.
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Hi Tiago! Yes, I have several Combine tutorials in my Continue Learning playlist. I also have some advanced videos coming soon!
@tmjromao
@tmjromao 2 жыл бұрын
@@SwiftfulThinking Excellent! good to know. Can't wait to learn more from you.
@worldofqurani1364
@worldofqurani1364 Жыл бұрын
is it worthing to write a 100 line for only a placeholder Color ! I would go with the regular swift ui one
@alexvaiman4966
@alexvaiman4966 5 ай бұрын
ohhhh after watching this video i came to fast conclusion.. I will never use swift UI in legacy project, so match setup and extra code )))
@hemantstha4144
@hemantstha4144 Жыл бұрын
Thank you very much
@HumbleHustle101
@HumbleHustle101 2 жыл бұрын
Nice Video. I am getting the protocol conformance errors as I am converting one conventional swift uwview to swiftui: "cannot convert value of type '(Binding) -> BaseListItemsSummaryCardView_SwiftUI' to expected argument type '(Binding) -> BaseListItemsSummaryCardView_SwiftUI' Cannot convert value of type '(Binding) -> BaseListItemsSummaryCardView_SwiftUI' to expected argument type '(Binding) -> BaseListItemsSummaryCardView_SwiftUI' initializer 'init(_:id:rowContent:)' requires that 'Counts' conform to 'MutableCollection' Initializer 'init(_:id:rowContent:)' requires that 'Counts' conform to 'MutableCollection' initializer 'init(_:id:rowContent:)' requires that 'Counts' conform to 'RandomAccessCollection' Initializer 'init(_:id:rowContent:)' requires that 'Counts' conform to 'RandomAccessCollection'" How can I deal with these?
@yourgflikesit
@yourgflikesit Жыл бұрын
Could you just use an observable object instead of the coordinator?
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
No, the protocol requires this Coordinator pattern here
@yourgflikesit
@yourgflikesit Жыл бұрын
@@SwiftfulThinking I just tested an it works if you add vc.vm = in both the makeui and updateui. You don’t even need the coordinator. It then works with a viewmodel. Which is much easier to work with.
How to use @ViewBuilder in SwiftUI | Advanced Learning #9
24:01
Swiftful Thinking
Рет қаралды 25 М.
마시멜로우로 체감되는 요즘 물가
00:20
진영민yeongmin
Рет қаралды 35 МЛН
DAD LEFT HIS OLD SOCKS ON THE COUCH…😱😂
00:24
JULI_PROETO
Рет қаралды 15 МЛН
The perfect imperfection of Google's Material You
15:47
David Imel
Рет қаралды 420 М.
This NEW SwiftUI Feature Is AMAZING | Navigation Stacks
20:05
Why You Should Use The SwiftUI Coordinator Pattern
18:45
Rebeloper - Rebel Developer
Рет қаралды 13 М.
Create custom Bindings in SwiftUI | Advanced Learning #27
30:41
Swiftful Thinking
Рет қаралды 4,6 М.
5 Things I Wish I Knew Before Learning Streamlit
21:34
Fanilo Andrianasolo
Рет қаралды 24 М.
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 795 М.