0

ProfileVC is a tab menu view. I pushed a SampleView with navigation controller from ProfileVC. If I dismiss SampleView i can see tabBar on ProfileVC but if i present ProfileVC from SampleView i cant see tabBar, it disappear.

Dismiss will be a problem for hiearchy. I need go directly profileView view

Thats push and back codes.

@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
    }

1 Answers1

0

Mainly because you are instantiate the UIViewController not the TabBar.

And the UIViewController is embedded inside the TabBar therefore,

You need to give your TabBarController on the IB an identifier,

and use that to present it, and it will switch to the first tab automatically.

     let TabBar = self.storyboard!.instantiateViewController(withIdentifier: "MyTabBarID")

      present(TabBar, animated: false, completion: nil) 

However, i don't know why not just dismiss the presented UINavigationController like this.

 self.navController.dismiss(animated: true) {
     self.navController = nil
}
Mohmmad S
  • 5,001
  • 4
  • 18
  • 50