title: Dismiss the xib view in swift
body: <p>I have created two xib files for my login condition. When first I click a button it presents the first xib file in that file there is another button on which when I click it to present another xib file upon the first one. Here I run my API and on success, I'm trying to dismiss the second xib file but it isn't dismissing the second xib. I have marked the breakpoint also and when I run it comes to the breakpoint but it isn't dismissing again. This is how I present my first xib file,</p>
  
  <pre><code>let signingAlert = SigningAlert()
  signingAlert.modalPresentationStyle = .custom
  present(signingAlert,animated: true,completion: nil)
  </code></pre>
  
  <p>and here I calling my second xib,</p>
  
  <pre><code>@IBAction func loginBtnTapped(_ sender: Any) {
  
      let loginAlert = LoginVC()
      loginAlert.modalPresentationStyle = .popover
      present(loginAlert,animated: true,completion: nil)
      // self.revealViewController().revealToggle(animated: true)
  }
  </code></pre>
  
  <p>and on my API success condition, I write this code for dismissing the xib's,</p>
  
  <pre><code>self.dismiss(animated: true, completion: nil)
  </code></pre>
  
  <p>That's what I'm writing an API. ` func loginAPICall(){</p>
  
  <pre><code>    activityIndicator.startAnimating()
      activityIndicator.isHidden = false
      shadowView.isHidden = false
  
      let param1 =  "username="+userNameTxt.text!
      let param2 =  param1+"&amp;password="+passwordTxt.text!
      let param  =  param2+"&amp;grant_type=password"
  
      print(param)
      LoginService.instance.LogInUSer(body: param) { (success) in
          if success{
  
              let status = LoginService.instance.status
  
              if status == 500{
                  print("500")
                  self.showAlert(message: "Error!.Server not found")
                  self.activityIndicator.stopAnimating()
                  self.activityIndicator.isHidden = true
                  self.shadowView.isHidden = true
              }
              else if status == 404{
                  print("404")
                  self.showAlert(message: "Error!. Data not found try again")
                  self.activityIndicator.stopAnimating()
                  self.activityIndicator.isHidden = true
                  self.shadowView.isHidden = true
              }
              else if status == 400{
                   self.showAlert(message: "Error!. Username or password is incorrect.")
                  self.activityIndicator.stopAnimating()
                  self.activityIndicator.isHidden = true
                  self.shadowView.isHidden = true
              }
              else if status == 401{
                  print("401")
                  self.activityIndicator.stopAnimating()
                  self.activityIndicator.isHidden = true
                  self.shadowView.isHidden = true
              }
              else if status == 200{
                  self.showsuccessAlert(message: "You are successfully LoggedIn")
                  self.dismiss(animated: true, completion: nil)
                  self.activityIndicator.stopAnimating()
                  self.activityIndicator.isHidden = true
                  self.shadowView.isHidden = true
  
                  let userName = LoginService.instance.loginModelInstance[0].userName
                  let accessToken = LoginService.instance.loginModelInstance[0].accessToken
                  let userId = LoginService.instance.loginModelInstance[0].userID
                  UserDefaults.standard.setValue("true", forKey: "status")
                  UserDefaults.standard.set(userName, forKey:"name")
                  UserDefaults.standard.set(userId, forKey:"userId")
                  UserDefaults.standard.set(accessToken, forKey:"accessToken")
                  UserDefaults.standard.synchronize()
              }
              else{
                  self.showAlert(message: "Error!. Try again")
                  self.activityIndicator.stopAnimating()
                  self.activityIndicator.isHidden = true
                  self.shadowView.isHidden = true
              }
          }else{
              let status = LoginService.instance.status
              print(status)
               self.showAlert(message: "Error!. Try again")
              self.activityIndicator.stopAnimating()
              self.activityIndicator.isHidden = true
              self.shadowView.isHidden = true
          }
      }
  }`
  </code></pre>
  
  <p>but it is not dismissing my xib's, how can I dismiss that? </p>