我正在尝试创建一个UIViewControllerRepresentable
结构体,但 Xcode 一直抱怨实现存根
struct PassVC: UIViewControllerRepresentable {
typealias UIViewControllerType = UIViewController
func makeUIViewController(context: Context) -> UIViewController {
let vc = UIViewController()
vc.view.backgroundColor = .yellow
return vc
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}
我先添加了 typealias,然后手动输入,最后让 Xcode 实现存根,也手动输入,但所有尝试都以 Xcode 报错,说没有实现存根。如果我点击“修复”,它会报错说存根方法需要重新声明。有人在 Xcode 中遇到过同样的问题吗?我的 Xcode 版本是 16.0。