Swiftui UIViewControllerRepresentable奇怪解除分配

Swiftui UIViewControllerRepresentable奇怪解除分配,swiftui,Swiftui,我有一个UIViewControllerRepresentable在SwiftUI中使用的UIViewController 当我从控制器导航回SwiftUI视图时,不会调用Denit(正如我所期望的那样) 但是,当我执行到UIViewControllerRepresentable的新导航时,首先调用deinit(对于以前的控制器) UIViewControllerRepresentable是否有我缺少的东西,为什么它不被释放 import SwiftUI import UIKit class

我有一个UIViewControllerRepresentable在SwiftUI中使用的UIViewController

当我从控制器导航回SwiftUI视图时,不会调用Denit(正如我所期望的那样)

但是,当我执行到UIViewControllerRepresentable的新导航时,首先调用deinit(对于以前的控制器)

UIViewControllerRepresentable是否有我缺少的东西,为什么它不被释放

import SwiftUI
import UIKit

class MyViewController: UIViewController {

    deinit() {
        print("This isn't called until the second initiation of the UIViewControllerRepresentable")
    }

}

struct MyViewControllerWrapper: UIViewControllerRepresentable {
    typealias UIViewControllerType = MyViewController

    func makeUIViewController(context: UIViewControllerRepresentableContext<MyViewControllerWrapper>) -> MyViewControllerWrapper.UIViewControllerType {
    
        let vc = UIViewControllerType(requestType: requestType)
        return vc
    }

    func updateUIViewController(_ uiViewController: MyViewControllerWrapper.UIViewControllerType, context: UIViewControllerRepresentableContext<MyViewControllerWrapper>) {
    
    }
}
导入快捷界面
导入UIKit
类MyViewController:UIViewController{
脱硝剂(){
print(“在第二次启动UIViewControllerRepresentable之前不会调用此命令”)
}
}
结构MyViewControllerRapper:UIViewControllerRepresentable{
typealias UIViewControllerType=MyViewController
func makeUIViewController(上下文:UIViewControllerRepresentableContext)->MyViewControllerRapper.UIViewControllerType{
设vc=UIViewControllerType(请求类型:请求类型)
返回vc
}
func updateUIViewController(uUIViewController:MyViewControllerRapper.UIViewControllerType,上下文:UIViewControllerRepresentableContext){
}
}

这是NavigationView的长期已知行为-它只是在被替换之前不会清除上次访问的视图,UIViewControllerRepresentable与此无关。谢谢,您能在哪里共享您发现此信息?