title: View not removed from its superview in iOS
body: <p>I have a <code>UIView</code> and a <code>collectionView</code>. If there is an internet connection I want to hide the <code>collectionView</code> and show the <code>UIView</code>, if not otherwise. </p>
  
  <pre><code>class MyClass{
      @IBOutlet weak var collectionView: UICollectionView!
      var myView : CustomView?
      ....
  
      func internetStatusChanegd(){
          if(isOnline){
              collectionView.isHidden = true
              if let viewNib = UIView.loadFromNibNamed("CustomView", bundle: Bundle.main) as? CustomView {
                  myView = viewNib
                  myView!.frame = self.view.bounds
                  self.view.addSubview(myView!)
              }
          }else{
              if let customView = myView{
                  customView.removeFromSuperview()
              }
              collectionView.isHidden = false
          }
      }
  }
  </code></pre>
  
  <p><code>removeFromSuperview()</code> Is called but the view is not removed from the view. Do you have an idea about the problem?</p>