Search code examples
iosswiftuiviewcontrolleruinavigationcontrollerpushviewcontroller

Push ViewController full screen from bottom inside ModalView


Inside my app I have a MainVC. From there I present another ViewControllerB and I would like to push inside there so this is how I achieve this:

let ViewControllerB = self.storyboard?.instantiateViewController(withIdentifier: "ViewControllerB") as! ViewControllerB
let navController = UINavigationController(rootViewController: communityVC)
self.present(navController, animated: true, completion: nil)

This is working exactly how I want it to work. However in ViewControllerB I also would like to push a certain ViewControllerC full screen from bottom and NOT just inside the modalView. I am calling this:

let firstLaunchVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FirstLaunchVC")
let transition:CATransition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
transition.type = CATransitionType.push
transition.subtype = CATransitionSubtype.fromTop
self.navigationController?.modalPresentationStyle = .fullScreen
self.navigationController!.view.layer.add(transition, forKey: kCATransition)
self.navigationController?.pushViewController(firstLaunchVC, animated: true)

This is pushing from the bottom but NOT fullscreen. I also get this message in the terminal:

Setting modalPresentationStyle once <UINavigationController: 0x1060f2a00> has been presented will have no effect until it is dismissed and presented again.

How can I push fullscreen from a presented ViewController?

I hope I made my problem clear. Let me know if you need more information on something.


Solution

  • I fixed it by calling this:

    let navigationController = UINavigationController(rootViewController: firstLaunchVC)
    navigationController.modalPresentationStyle = .fullScreen
    present(navigationController, animated: true)
    

    This is working exactly how I want it to work, even though I am not quite sure if I am messing up my ViewController-Hirarchy... anyway it is working :D thanks for the help