即使调用viewcontrollers的函数似乎正在运行,我也遇到了我的viewcontrollers问题 . 我在控制台中收到的错误是:
警告:尝试显示其视图不在窗口层次结构中!
我已经尝试了关于“尝试在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)
}
}
调用该函数并且print语句有效 . 但是,视图控制器不会出现 .
1 回答
你必须在
if
之外创建presentNewPage()函数???像这样改变它