Swift:线程1:在storyBoard.instantiateViewController之后发出SIGABRT信号

时间:2018-03-03 21:25:15

标签: ios swift uistoryboard

我希望切换用户到另一个页面

我使用此代码:

let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let vcAboutUs = storyBoard.instantiateViewController(withIdentifier: "ViewControllerIndex") 
self.present(vcAboutUs, animated: true, completion: nil)

但是在运行项目后,我收到Thread 1: signal SIGABRT错误并且模拟器崩溃了

图片:https://i.stack.imgur.com/d1uIT.jpg

完整代码:

DispatchQueue.global(qos: .background).async {
  let getJsonLogin = GetData()
  let result = getJsonLogin.getJson(urlGet: AppDelegate.ADDRESS+"/index.php", urlData: "mobile="+mobile+"&code="+getCode+"") { result in
  DispatchQueue.main.async {
    if(result == nil){
      self.progressText.text = "Error";
    } else {
      if((result!["error"]!) == "true"){
        self.progressTextCode.text = result!["message"]!;
      } else {
        let storyBoard = UIStoryboard(name: "Main", bundle: nil)
        let vcAboutUs = storyBoard.instantiateViewController(withIdentifier: "ViewControllerIndex") 
        self.present(vcAboutUs, animated: true, completion: nil)
      }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

您是否在故事板中添加了VC的名称?

enter image description here