【发布时间】:2018-12-17 12:06:14
【问题描述】:
我遇到了我的视图控制器没有显示的问题,即使调用视图控制器的函数似乎正在运行。我在控制台中收到的错误是:
警告:尝试呈现不在窗口层次结构中的视图!
我已经尝试了关于“尝试在其视图不在窗口层次结构中的 UIViewController 上呈现 UIViewController”线程的建议,但没有任何进展。我正在以编程方式运行所有内容。
func handleNewPage(){
print("this code works")
let uid = Auth.auth().currentUser?.uid
ref = Database.database().reference()
let usersReference = ref.child("patient").child((uid)!)
if usersReference.child("Doctor Code") != nil {
func presentNewPage(){
let firstPage = LandingPage()
let navCon = UINavigationController(rootViewController: firstPage)
present(navCon, animated: true, completion: nil)
}
presentNewPage()
print("PRINT")
} else{
let newPage = PresentViewController() // doctor reg page
let navController = UINavigationController(rootViewController: newPage)
present(navController, animated: true, completion: nil)
}
}
函数被调用并且打印语句出来是有效的。然而,视图控制器不会出现。
【问题讨论】:
-
什么调用了这个函数,你在这个函数之前有没有控制器?
标签: ios swift uiviewcontroller