Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is the sheet modal backed by a uiviewcontroller?


Asked by Avery Robbins on Dec 14, 2021 FAQ



After researching it a bit, .sheet () modals, are in fact, backed by a real UIViewController. The challenge is tapping into the backing UIViewController of our SwiftUI modal. This article, will be all about it. It may seem too much code to accomplish something so simple.
One may also ask,
The process of integrating UIView is almost identical to the one of UIViewController. Namely, the SwiftUI view must conform to the UIViewRepresentable protocol and implement the same set of methods. Here is an example of how we can represent UIActivityIndicatorView in SwiftUI:
Subsequently, The UIViewController class defines the shared behavior that is common to all view controllers. You rarely create instances of the UIViewController class directly. Instead, you subclass UIViewController and add the methods and properties needed to manage the view controller's view hierarchy.
In fact,
Apple may change the way modals are presented in SwiftUI, which may in turn render this article completely useless. But this blog is all about experimenting and learning… so the content of this post, is indeed, relevant.
Accordingly,
If none of the view controller’s views handle an event, the view controller has the option of handling the event or passing it along to the superview. View controllers are rarely used in isolation. Instead, you often use multiple view controllers, each of which owns a portion of your app’s user interface.