替换的rootViewController在后台仍然可见

时间:2017-07-11 08:25:50

标签: ios swift

当我的应用程序通过用户对通知的响应从后台打开时,我会根据通知将它们指向相应的屏幕。该过程涉及替换AppDelegate中的window.rootViewController

以下是我处理通知的代码:

if application.applicationState == .background {
    let info = userInfo["custom"] as! [AnyHashable : Any]
    let a = info["a"] as! [AnyHashable : Any]

    switch a["notificationType"] as! Int {
    case 1:
        let newVC = StoryBoardInstantiation.instantiateNewContentViewController(true)
        let leftVC = StoryBoardInstantiation.instantiateLeftPanelVC()
        let sideMenu = SSASideMenu(contentViewController: UINavigationController(rootViewController: newVC), leftMenuViewController: leftVC)

        self.window?.rootViewController = sideMenu
    }
}

之后,当用户在应用程序中导航时,只要对视图控制器进行动画更改,原始ViewController(代码中替换的那个)将在后台显示。

如何删除之前已替换的rootViewController?

0 个答案:

没有答案