I have the code to go to the next page and show the tabbar when I click the button.
@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)
}
My question is, when I go to another page using the tab bar on the next page and then return, I want to show the main page.
Currently, when I move using the tab bar and then come back, the next page is displayed as it is.
How can I fix it?
Add this to your nextPageCon
view controller:
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.presentingViewController?.dismiss(animated: false, completion: nil)
}
When you present nextPageCon
and then navigate away by selecting a different tab, this func will trigger and dismiss itself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.