Chapter 9
Using Legacy UIKit Views and View Controllers in SwiftUI
IN THIS CHAPTER
Understanding the UIKit View Controller life cycle
Understanding the SwiftUI view life cycle
Using UIKIt views in SwiftUI through the UIViewRepresentable protocol
Using UIKIt view controllers in SwiftUI through the UIViewControllerRepresentable protocol
SwiftUI comes with a number of views that make creating user interfaces (UIs) for your applications very easy. It is, nevertheless, still in its early days. A number of popular views and view controllers still have not been ported over to SwiftUI. For example, the Activity Indicator and WebView views in UIKit
and the Image Picker and Contacts Picker view controllers are just some of the views and view controllers that have yet to port to SwiftUI.
Fortunately, SwiftUI works seamlessly with the existing UIKit
frameworks on all Apple platforms — you can place UIKit
views and view controllers within SwiftUI views and vice versa.
In this chapter, I show you how to use the existing UIKit
views and view controllers in SwiftUI. I recap the way things are done ...
Get SwiftUI For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.