我有代码可以在单击按钮时转到下一页并显示选项卡栏。
@IBAction func moveBtn(_ sender: Any) {
guard let next = self.storyboard?.instantiateViewController(withIdentifier: "nextPage") as? nextPageCon else {
return
}
self.definesPresentationContext = true
next.modalPresentationStyle = .overCurrentContext
self.present(next, animated: false)
}
我的问题是,当我使用下一页上的标签栏转到另一个页面然后返回时,我想显示主页。
目前,当我使用标签栏移动然后返回时,下一页将按原样显示。
如何修复它?
最佳答案
将其添加到您的 nextPageCon
View Controller 中:
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.presentingViewController?.dismiss(animated: false, completion: nil)
}
当您呈现 nextPageCon
,然后通过选择不同的选项卡导航离开时,此函数将触发并自行关闭。
关于ios - swift4中点击标签栏时如何始终显示主页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53729274/