【问题标题】:UIHostingController as Class VariableUIHostingController 作为类变量
【发布时间】:2022-06-14 00:14:49
【问题描述】:

如何将 UIHostingController 创建为类中的变量?尝试时出现此错误:Reference to generic type 'UIHostingController' requires arguments in <...> 在类变量和初始化中。我将使用不同的视图,所以我不能明确引用它们,我怎样才能使它通用?

class SomeNode {
        let vc: UIHostingController?
        let id: Int!
        
        init(id: Int, vc: UIHostingController?) {
            self.id = id
            self.vc = vc
        }
    }

【问题讨论】:

  • 您能简单地将vc 声明为超类UIViewController 吗?您是否真的需要任何UIHostingController 特定功能才能从SomeNode 访问?

标签: ios swift swiftui uihostingcontroller


猜你喜欢
  • 2023-03-12
  • 1970-01-01
  • 1970-01-01
  • 2015-08-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-01
  • 2015-09-17
相关资源
最近更新 更多