【发布时间】: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