我们要求使用具有以下功能的navigationcontroller来呈现ViewController:
为实现这一目标,我们提出了一个带有新ViewController的navigationController作为根视图控制器。
@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)
}
但不知怎的,弹出窗口显示在半屏幕上。
如果我们将展示pvc(没有NavigtaionController的ViewController),那么它可以很好地工作。
self.present(pvc, animated: true, completion: nil)
请建议使用navigationController实现相同功能。