We have a requirement to presentViewController with navigationcontroller with following features:
- User should be able to navigate within presented view controller and maintain a navigation stack.
- Presented View Controller with Navigation Bar should only acquire 75% of screen area.
To achieve this we presented a navigationController with new ViewController as root View Controller.
@IBAction func openModal(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let pvc = storyboard.instantiateViewController(withIdentifier: "ViewControllerA") as UIViewController
pvc.modalPresentationStyle = UIModalPresentationStyle.custom
pvc.transitioningDelegate = self as? UIViewControllerTransitioningDelegate
let navController = UINavigationController(rootViewController: pvc) // Creating a navigation controller with VC1 at the root of the navigation stack.
self.present(navController, animated:true, completion: nil)
}
func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
return HalfSizePresentationController(presentedViewController: presented, presenting: presentingViewController)
}
But somehow the popup appearing is not showing on half screen.
If we will present the pvc (ViewController without NavigtaionController), then it works perfectly.
self.present(pvc, animated: true, completion: nil)
Please suggest to achieve the same with navigationController.