ProfileVC是一个选项卡菜单视图。我从ProfileVC推送了带有导航控制器的SampleView。如果我关闭SampleView,我可以在ProfileVC上看到tabBar,但是如果我从SampleView中看到ProfileVC,则看不到tabBar,它将消失。
解雇将是一个问题。我需要直接进入profileView视图
多数民众赞成在推回代码。
@IBAction func goToToolbox(_ sender: Any) {
let transition = CATransition()
transition.duration = 0.3
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
view.window!.layer.add(transition, forKey: kCATransition)
let presentedVC = self.storyboard!.instantiateViewController(withIdentifier: "ToolboxVC")
presentedVC.navigationController?.navigationBar.backgroundColor = UIColor.cyan
let nvc = UINavigationController(rootViewController: presentedVC)
present(nvc, animated: false, completion: nil)
}
@objc func didTapCloseButton(_ sender: Any) {
if let presentedVC = presentedViewController {
let transition = CATransition()
transition.duration = 0.3
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromLeft
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
presentedVC.view.window!.layer.add(transition, forKey: kCATransition)
}
let profileVC = self.storyboard!.instantiateViewController(withIdentifier: "ProfileVC")
present(profileVC, animated: false, completion: nil)
presentedVC = nil
}
答案 0 :(得分:0)
主要是因为您实例化了UIViewController
而不是TabBar
。
UIViewController
嵌入在TabBar
内,
您需要在TabBarController
上为您的IB
指定一个标识符
并使用它来显示它,它将自动切换到第一个标签。
let TabBar = self.storyboard!.instantiateViewController(withIdentifier: "MyTabBarID")
present(TabBar, animated: false, completion: nil)
但是,我不知道为什么不dismiss
像这样展示UINavigationController
。
self.navController.dismiss(animated: true) {
self.navController = nil
}