我有一个activityfeedVC。如果用户单击 tableViewCell,则会显示 ActivityVC。在这个 VC 中,我有一个“后退”按钮。单击此按钮后,我想返回到上一个 View Controller 。我能够实现这一点,但无法显示 tabBarController。我正在使用完成处理程序,但出了点问题。希望你能帮忙。
import UIKit
class activityVC: UIViewController {
@IBAction func backBtnWasPressed(_ sender: Any) {
// Navigates back
let feedVC = storyboard?.instantiateViewController(withIdentifier: "feedVC")
func completionHandler() {
// show the tabBarController - NOT WORKING
feedVC?.tabBarController?.tabBar.isHidden = false
print("tabBarController shown")
}
present(feedVC!, animated: false, completion: completionHandler)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
我想我应该使用 UINavigationBar 而不是我的客户导航...也许这更容易,即使我没有很多需要此功能的 View ...
最佳答案
您是否将 ActivityVC 推送到 View Controller 堆栈上?如果是这样,您只需在用户点击后退按钮时弹出 ActivityVC 即可。
class activityVC: UIViewController {
@IBAction func backBtnWasPressed(_ sender: Any) {
self.navigationController?.popViewController(animated: false)
}
}
关于ios - 按下按钮时呈现新 ViewController 时如何显示 tabBarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47237803/