关闭抽屉控制器后,swift4 中将调用哪个视图控制器生命周期方法?

After closeing MMDrawer Controller which view controller life cycle method will called in swift4?

我有一个标签栏控制器,在那个标签栏内我有五个视图控制器。我还有一个位于 homeVC 上的右视图控制器(抽屉)。对于 rightViewController,我使用 MMDrawerController 来源:https://www.youtube.com/watch?time_continue=1468&v=TdKnImb4SWs。在 appdelegate 中。现在当右视图控制器关闭时,视图控制器的哪个生命周期被调用?因为我想写一个函数。我在 appdelegate

上使用了这段代码
    let rightViewController = mainStoryboard.instantiateViewController(withIdentifier: "RightViewVC") as! RightViewVC



       UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]

    let rightSideMenuNav = UINavigationController(rootViewController: rightViewController)
    drawerController = MMDrawerController(center:mainPage,rightDrawerViewController:rightSideMenuNav)

   // drawerController!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.panningCenterView
    drawerController!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.panningCenterView
    drawerController!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.all
    drawerController!.preferredInterfaceOrientationForPresentation = MMDrawerOpenCenterInteractionMode.full

    window?.rootViewController = drawerController

home ViewController 中的 viewwillApear() 将在右侧 ViewController 关闭时被调用。

尝试在每个 viewDidLoad 中打印以查看活动控制器:

if let window = UIApplication.shared.delegate?.window {
    if var viewController = window?.rootViewController {
        // handle navigation controllers
        if(viewController is UINavigationController){
            viewController = (viewController as! UINavigationController).visibleViewController!
        }
        print(viewController)
    }
}

if self.window.rootViewController is MyViewController {
    //do something if it's an instance of that class
}

MM Drawer 在打开、关闭或切换抽屉时提供完成块,您只需要比较抽屉关闭或打开等事件就可以成功。这是代码

@IBAction func rightMenuButtonTapped(_ sender: Any) { 

    let appdelegate = UIApplication.shared.delegate as! AppDelegate 

    appdelegate.drawerController?.toggle(MMDrawerSide.right, animated: true){ (isCompleted) in 
            if appdelegate.drawerController?.openSide == MMDrawerSide.none 
            { 
                 print("drawer close")
                 if let objHome = appdelegate.drawerController?.centerViewController as? HomeVC{ 
                      print("Got Home VC") 
                 }  
            } 
            else if appdelegate.drawerController?.openSide == MMDrawerSide.right 
            { 
                 print("drawer open") 
            } 
     }
}