title: Swift remove subviews from superview
body: <p>i have a scrollView, and i added a refreshcontroll to it. </p>
  
  <pre><code>self.refreshControl = UIRefreshControl()
  self.refreshControl.attributedTitle = NSAttributedString(string: "Frissítéshez húzzad! :)")
  self.refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
  self.scrollView.addSubview(refreshControl)
  </code></pre>
  
  <p>in the refresh method i have to remove all subviews from the scrollview, then repopulate the scrollview..</p>
  
  <pre><code>self.refreshControl = UIRefreshControl()
  self.refreshControl.attributedTitle = NSAttributedString(string: "Frissítéshez húzzad! :)")
  self.refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
  self.scrollView.addSubview(refreshControl)
  </code></pre>
  
  <p>after i try to pull, my scrollview get new data but it's don't have anymore refreshcontroll. i think it is because when i removing subviews from my scrollview i also remove the refreshcontroll from it. (if i add the refreshcontroll again in my refresh method my scrollview will have refreshconroll again)  But there is another problem. After refreshing my scrollview moving down.. i attached to pictures: </p>
  
  <p>This is how i remove the subiews:</p>
  
  <pre><code>func refresh(sender:AnyObject)
  {
      //remove all subviews from scrollview..
      let subViews = self.scrollView.subviews
      for subview in subViews{
          println("for removing...")
          subview.removeFromSuperview()
      }
  
      println("refresh called..")
      UIApplication.sharedApplication().applicationIconBadgeNumber = 0
      //remove all elements from the array
      tstFrames.removeAll(keepCapacity: false)
      //refresh data from webservice and adding it to tstFrames Array
      wsServiceFeedTst()
      //adding items to the scrollview from tstFramesArray
      addPosts()
      self.refreshControl.endRefreshing()
  
  }
  </code></pre>
  
  <p>This is how scrollview look like before refreshing:
  <img src="https://i.stack.imgur.com/rFfiI.png" alt="enter image description here">  </p>
  
  <p>An this is how it looks like after refreshing:
  <img src="https://i.stack.imgur.com/BtCoS.png" alt="enter image description here"></p>
  
  <p>could anybody help me about why is this moving down? </p>
  
  <p>Thank you! </p>
  
  <p>Thank you, this is the solution:</p>
  
  <pre><code>let subViews = self.scrollView.subviews
  for subview in subViews{
      println("for removing...")
      if (subview is PostLineItem) {
          subview.removeFromSuperview()
      }
      else {
          println("not removing..")
      }
  }
  </code></pre>