如何迅速应用礼物

时间:2018-12-30 09:05:12

标签: ios swift viewcontroller

我的Swift 4应用程序遇到问题。 当我的字符串获得不带nil的值时,我想自动移动视图控制器。 (建议)

但是它根本不起作用。

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);
}

“日志情节提要”的消息正常打印。 但是self.present线根本无法工作。

如何解决我的问题?

1 个答案:

答案 0 :(得分:2)

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

在2种情况下无效

1-在此行中运行的当前vc当前尚未完全布局-例如在viewDidLoad

2-当前的vc当前正在显示另一个vc