ios - 关闭抽屉 Controller 后,swift4中将调用哪个 View Controller 生命周期方法?
<p><p>我有一个标签栏 Controller ,在该标签栏内我有五个 ViewController 。我也有一个在 homeVC 上的右 ViewController (抽屉)。对于 rightViewController 我使用 MMDrawerController 来源:<a href="https://www.youtube.com/watch?time_continue=1468&v=TdKnImb4SWs" rel="noreferrer noopener nofollow">https://www.youtube.com/watch?time_continue=1468&v=TdKnImb4SWs</a> .在 appdelegate 中。现在当右 ViewController 关闭时, ViewController 的哪个生命周期被调用?因为我想写一个函数。我在 appdelegate 上使用过这段代码</p>
<pre><code> let rightViewController = mainStoryboard.instantiateViewController(withIdentifier: "RightViewVC") as! RightViewVC
UINavigationBar.appearance().titleTextAttributes =
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
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>MMDrawer 在打开、关闭或切换抽屉时提供完成 block ,您只需比较抽屉关闭或打开等事件即可获得成功。这是代码</p>
<pre><code>@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")
}
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 关闭抽屉 Controller 后,swift4中将调用哪个 ViewController 生命周期方法?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/51568270/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/51568270/
</a>
</p>
页:
[1]