转换到另一个时出现黑屏 ViewController

Getting black screen while transition to another ViewController

我正在尝试转移到另一个 ViewController 但它让我黑屏!这是我的代码:

                            if (content == nil) {
                            let sec: testViewController = testViewController(nibName: nil, bundle: nil)
                            self.present(sec, animated: true, completion: nil)
                        }

在情节提要中:

您只是想尝试另一种方式来以编程方式显示您的目的地ViewController。试试这个,

let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 
let myViewController: UIViewController = storyBoard.instantiateViewControllerWithIdentifier("<myViewControllerRestorationID>") //if you have the restoration ID, otherwise use 'ModalViewController'
self.presentViewController(myViewController, animated: true, completion: nil)

从主故事板中将故事板 ID 提供给 testViewController。

if content == nil {
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let sec: testViewController = storyboard.instantiateViewController(withIdentifier: "testViewController") as! testViewController
    self.present(sec, animated: true, completion: nil)
    }

在 Storborad 中提供故事板 ID ex-->testViewControllerId 并检查 UseStoryboard Id

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let testController = storyboard.instantiateViewController(withIdentifier :"testViewControllerId") as! testViewController
self.present(testController, animated: true)