Objective c 以编程方式更改导航根视图目标c

Objective c 以编程方式更改导航根视图目标c,objective-c,xcode,appdelegate,uiscenedelegate,Objective C,Xcode,Appdelegate,Uiscenedelegate,我想使用objective c以编程方式更改导航的根视图控制器。我用的是故事板。我试图在app delegate中更改它,但没有成功,引入了一种新的称为scene delegate的东西,我相信我可以从那里更改根,但我没有找到这方面的资源。有人能帮忙吗?使用以下代码: class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: U

我想使用objective c以编程方式更改导航的根视图控制器。我用的是故事板。我试图在app delegate中更改它,但没有成功,引入了一种新的称为scene delegate的东西,我相信我可以从那里更改根,但我没有找到这方面的资源。有人能帮忙吗?

使用以下代码:

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?
    
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    
        if let windowScene = scene as? UIWindowScene {
            let window = UIWindow(windowScene: windowScene)
            window.rootViewController = MyRootViewController()
            self.window = window
            window.makeKeyAndVisible()
        }
     }
参考:

以及: