当在Appdelegate中未设置rootcontroller时,视图隐藏在状态栏后面

时间:2018-05-14 17:45:59

标签: ios swift uiview uinavigationbar uistatusbar

在我的AppDelegate.swift中,我检查用户是否已登录

if let currentUser = Auth.auth().currentUser{
    self.window?.rootViewController = self.storyboard?.instantiateViewController(withIdentifier: "HomeScreen")
}else{
    self.window?.rootViewController = self.storyboard?.instantiateViewController(withIdentifier: "LoginScreen")
}

如果用户未登录,他们会被重定向到LoginScreen,他们可以登录,然后按如下方式呈现HomeScreen

UIApplication.shared.keyWindow?.window?.rootViewController = self.storyboard?.instantiateViewController(withIdentifier: "HomeScreen")

我的HomeScreen是一个NavigationController,它将重定向到ViewController,在那里我添加我的视图如下:

UIApplication.shared.keyWindow?.addSubview(newView!)

当我的应用从AppDelegate直接运行到我的HomeScreen时,newView将显示在我的StatusBar上方,就像它应该的那样。如果用户从登录屏幕登录后显示HomeScreen,则newView将显示在statusBar后面。

在第二种情况下,我的视图显示在状态栏下方的问题是什么?

编辑:我可能还会添加newView是一个滑动手势来显示它。

This is how it looks when a user login through LoginScreen

This is how it should look and does when you get redirected to HomeScreen from AppDelegate.swift

0 个答案:

没有答案