ios - 呈现 VC 时出现问题,屏幕变黑

标签 ios swift viewcontroller

我试图在用户登录后显示 VC。但是登录成功后,VC 变黑。演示发生的情况是here并且有相同的图像。我在 stackoverflow 上找到了文章,但其中任何一篇都没有帮助我。 enter image description here enter image description here enter image description here enter image description here 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”。

enter image description here

让我知道它是否有效。 :)

关于ios - 呈现 VC 时出现问题,屏幕变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44655517/

相关文章:

objective-c - 当我们从 UIWebView 向下滚动时如何触发一个方法?

ios - 每次将新的 tableViewCell 添加到 UITableView 时如何调用函数

ios - AppDelegate 中需要任何用于第二个核心数据实体的代码吗?

ios - 如何打开新 View 并杀死实际 View ?

ios - 如何创建小型 tableView Controller ?

ios - 以编程方式在 UIView 上设置 ViewController

ios - 更新后 RealmSwift 崩溃并出现错误 "Invalid property name"

ios - 目标 ViewController 在 segue 后没有改变

ios - 为什么 removeAllObservers() 在 deinit 中不起作用?

ios - Swift - 使用未声明的类型 'GTMOAuth2Authentication'