HostingController

@MainActor
open class HostingController : UIHostingController<AnyView>

SwiftUI控制器包装类,可将View事件用delegate代理到VC

Controller在MVVM中也为View的角色,可持有ViewModel,负责生命周期和界面跳转

Lifecyecle

  • Undocumented

    Declaration

    Swift

    @MainActor
    public init()
  • Declaration

    Swift

    @MainActor
    public dynamic required init?(coder aDecoder: NSCoder)

Setup

  • 初始化导航栏,子类重写

    Declaration

    Swift

    @MainActor
    open func setupNavbar()
  • 初始化子视图,子类重写,可结合StateView实现状态机

    Declaration

    Swift

    @MainActor
    open func setupSubviews()