I have a scrollView and I added a refreshcontroll to it.
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)
in the update method, I have to remove all subviews from scrollview, and then re-fill the scroll.
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)
after I try to pull, my scrollview will get new data, but it no longer has refreshcontroll. I think this is because when I remove subviews from my scrollview, I also remove refreshcontroll from it. (if I add refreshcontroll to my update method again, my scrollview will have refreshconroll again). But there is another problem. After updating my scroll down. I am attached to photos:
This is how I delete the fields:
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() }
Here's what scrollview looks like before upgrading: 
Here's what it looks like after the update: 
Can someone help me on why this is happening?
Thanks!
Thanks, this solution:
let subViews = self.scrollView.subviews for subview in subViews{ println("for removing...") if (subview is PostLineItem) { subview.removeFromSuperview() } else { println("not removing..") } }