UIHostingController

open class UIHostingController : UINavigationController
extension UIHostingController: UINavigationControllerDelegate
extension UIHostingController: UIGestureRecognizerDelegate

The UIKit ViewController that acts as parent of a AltSwiftUI View hierarchy.

Initialize this controller with the view that you want to place at the top of the hierarchy.

When using UIKit views, it’s possible to interact with a AltSwiftUI views by passing a UIHostingController that contains a View hierarchy.

  • Overrides the behavior of the current interactivePopGesture and enables/disables it accordingly. This property is true by default.

    Important

    Not SwiftUI compatible.

    Note

    Different to using UINavigationController’s interactivePopGesture?.isEnabled, this property is able to turn on/off the gesture even if there is no existent navigationBar or if the leftBarButtonItem is set.

    Declaration

    Swift

    public static var isInteractivePopGestureEnabled: Bool
  • Declaration

    Swift

    public init(rootView: View, background: UIColor? = nil)
  • Declaration

    Swift

    override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?)
  • Declaration

    Swift

    public required init?(coder aDecoder: NSCoder)
  • Declaration

    Swift

    override public func pushViewController(_ viewController: UIViewController, animated: Bool)
  • Set this property to use a custom implementation for the application’s root UIHostingController when there is a TabView in the hierarchy. The TabView will cause the root controller to be recreated, so don’t subclass a UIHostingController and replace it in the app’s delegate.

    Declaration

    Swift

    public static var customRootTabBarController: SwiftUITabBarController
  • Declaration

    Swift

    public func navigationController(
        _ navigationController: UINavigationController,
        didShow viewController: UIViewController,
        animated: Bool)
  • Declaration

    Swift

    public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool