Attempt to present UIViewController on UIViewController whose view is not in the window hierarchy

后端 未结 30 3130
一整个雨季
一整个雨季 2020-11-21 23:39

Just started using Xcode 4.5 and I got this error in the console:

Warning: Attempt to present < finishViewController: 0x1e56e0a0 > on < ViewCont

30条回答
  •  遥遥无期
    2020-11-21 23:55

    I had similar issue on Swift 4.2 but my view was not presented from the view cycle. I found that I had multiple segue to be presented at same time. So I used dispatchAsyncAfter.

    func updateView() {
    
     DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
    
    // for programmatically presenting view controller 
    // present(viewController, animated: true, completion: nil)
    
    //For Story board segue. you will also have to setup prepare segue for this to work. 
     self?.performSegue(withIdentifier: "Identifier", sender: nil)
      }
    }
    

提交回复
热议问题