title: removeFromSuperview() not always working
body: <p>I declare a UIView variable called var progressBar : UIView?</p>
  
  <p>and I show it or hide the view with this function</p>
  
  <pre><code>func showProgressBar(showBar: Bool){
  if showBar{
              let viewHeight = view.frame.size.height
              progressBar = Bundle.main.loadNibNamed("progressBar", owner: nil, options: nil)?.first as? UIView
              progressBar?.frame = CGRect(x: 0, y: viewHeight - 80 , width: self.view.frame.width, height: 80)
              if let bar = progressBar{
                  self.view.addSubview(bar)
              }
          }else{
              DispatchQueue.main.async() {
                  self.progressBar?.removeFromSuperview()
              }
          }
  </code></pre>
  
  <p>Sometimes when I navigate a bit between the views I am not able to hide the progress bar, even when <code>self.progressBar?.removeFromSuperview()</code> is executed. It looks to me like if the view has lost the reference to the old progress bar... Do you have an idea about the problem and how I could fix it?</p>