如何在 swift 中正确应用礼物

How do I apply present working properly in swift

我在 swift 4 的申请中遇到了问题。 当我的字符串得到一个没有 nil 的值时,我想自动移动我的视图控制器。 (Promatically)

然而它根本不起作用。

if(rst_str != nil){
    let nextView = storyboard?.instantiateViewController(withIdentifier: "viewListController") as! ViewListController

    //viewListController.delegate = self;

    print("log storyboard");

    self.present(nextView, animated: true, completion: nil);
}

"log storyboard"的消息打印正常。 但是 self.present 行根本不起作用。

我该如何解决我的问题?

 self.present(nextView, animated: true, completion: nil);

在 2 种情况下不起作用

1-当前vc你运行这一行目前还没有完全布局-比如在viewDidLoad

2- 当前 vc 目前正在呈现另一个 vc