模态视图不包括整个屏幕

时间:2018-03-30 19:57:47

标签: ios swift uinavigationcontroller uitabbarcontroller modalviewcontroller

我有一个应用程序,每次打开应用程序时都需要显示PIN码屏幕。我成功地显示了模态视图,但它没有覆盖顶部的导航栏,也没有覆盖底部的标签栏。我相信这是因为我如何呈现它,但我没有看到改变它的方法。

这就是我呈现控制器的方式

let newVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "LoginView")
let view = window?.rootViewController as! UITabBarController
view.selectedViewController?.show(newVC, sender: nil)

这是一个故事板,可以让您了解该应用。 enter image description here

1 个答案:

答案 0 :(得分:3)

问题在于您使用UIViewController's api,show。在这种情况下,该函数被UINavigationController覆盖,push将用于呈现视图控制器。如果您的计划是以模态方式呈现视图控制器,而是使用present

selectedViewController?.present(newVC, animated: true, completion: nil)