我在导航控制器中嵌入了一个视图控制器。这个导航控制器是我的标签栏控制器内的第三个项目。我想以模态方式呈现视图控制器。
这是我试过的,但它不运行
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
// CameraView is the Storyboard ID of the VC I want to present
if viewController is EditPreviewVideosViewController {
if let newVC = tabBarController.storyboard?.instantiateViewController(withIdentifier: "CameraView") {
// None of this prints
print()
print("new vc is allowed")
print()
tabBarController.navigationController?.present(newVC, animated: true, completion: {
print("complete")
})
return false
}
}
return true
}
从 tabbarController childs 获取正确的导航控制器
if let nav = tabBarController.viewControllers[tabBarController.selectedIndex] as UINavigationController {
nav.present(newVC, animated: true, completion: {
print("complete")
})
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句