我试图在用户登录后显示 VC。但是登录成功后,VC 变黑。演示发生的情况是here并且有相同的图像。我在 stackoverflow 上找到了文章,但其中任何一篇都没有帮助我。 enter image description here
最佳答案
试试这个代码:
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc: ALMainController = storyboard.instantiateViewController(withIdentifier: "ALMainController") as! ALMainController
self.present(vc, animated: true, completion: nil)
或者你可以使用这个:
let firstPage = self.storyboard?.instantiateViewController(withIdentifier: "ALMainController")as! ALMainController
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = firstPage
两者都应该有效。
并且不要忘记在您的 Storyboard ID 中写入:“ALMainController”。
让我知道它是否有效。 :)
关于ios - 呈现 VC 时出现问题,屏幕变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44655517/