简体   繁体   English

模态视图不包括整个屏幕

[英]Modal view doesn't cover whole screen

I have an app that I need to display a pin code screen every time the app is opened. 我有一个应用程序,每次打开应用程序时我都需要显示一个pin代码屏幕。 I'm successfully displaying the modal view, but it doesn't cover the navigation bar at the top, and it doesn't cover the tab bar at the bottom. 我成功地显示了模态视图,但它没有覆盖顶部的导航栏,也没有覆盖底部的标签栏。 I believe it's because of how I'm presenting it, but I'm not seeing a way to change it. 我相信这是因为我如何呈现它,但我没有看到改变它的方法。

This is how I'm presenting the controller 这就是我呈现控制器的方式

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

This is the storyboard to give you an idea of the app. 这是一个故事板,可以让您了解该应用程序。 在此输入图像描述

The problem is your use of UIViewController's api, show . 问题是你使用UIViewController's api, show The function is overridden by UINavigationController in this case and push will be used to present the view controller. 在这种情况下,该函数被UINavigationController覆盖, push将用于呈现视图控制器。 If your plan is to modally present a view controller, rather use present 如果您的计划是以模态方式呈现视图控制器,而是使用present

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM