Warning: Attempt to present * on * which is already presenting (null)

后端 未结 16 769
盖世英雄少女心
盖世英雄少女心 2021-02-03 17:14

This is my first application for iOS.

So I have a UIVIewController with a UITableView where I have integrated a UISearchBar and a

16条回答
  •  感情败类
    2021-02-03 17:34

    For me it was an alert that was interfering with the new VC that I was about to present.

    So I moved the new VC present code into the OK part of my alert, Like this :

        func showSuccessfullSignupAndGoToMainView(){
    
        let alert = UIAlertController(title: "Alert", message: "Sign up was successfull.", preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
            switch action.style{
            case .default:
                // Goto Main Page to show businesses
                let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
                let vc : MainViewController = mainStoryboard.instantiateViewController(withIdentifier: "MainViewController") as! MainViewController
                self.present(vc, animated: false, completion: nil)
    
            case .cancel:
                print("cancel")
    
            case .destructive:
                print("destructive")
    
            }}))
        self.present(alert, animated: true, completion: nil)
    }
    

提交回复
热议问题