1
我有一個collectionView
從網絡中提取數據,然後用戶刪除一個對象,我想顯示剩餘的對象。由於過去的噩夢在索引處刪除對象,並且雜耍我的本地數據與網絡版本同步,所以我可以做一個新的調用來獲取新的網絡數據(少於刪除的對象),因爲它沒有那麼多。這就是說,在仍然存在的collectionView
中顯示新數據的最佳方法是什麼?我有點想扔出collectionView
(與舊數據)並添加一個新的,但沒有這樣的方法可以做這樣的事情嗎?或者只是刷新整個collectionViewController
?想在這裏找出最佳辦法,而不是一個黑客=)刪除對象後重新加載CollectionViewController?
func getPinsCheckLinksAndStartLoadAnimation() {
PinterestRequest().getPinterstPins(board: board) { (result) in
LinkCheck().checkLinks(pins: result, handler: { (testPinsWithBrokenLinks, error) in
self.pinsWithBrokenLinks = testPinsWithBrokenLinks
})
self.startAnimating(self.view.frame.size, message: "Checking Pins...", messageFont: UIFont.boldSystemFont(ofSize: 16), type: .ballScaleMultiple, color: UIColor.red, padding: CGFloat(0), displayTimeThreshold: nil, minimumDisplayTime: nil, backgroundColor: UIColor.clear, textColor: UIColor.black) //see https://github.com/ninjaprox/NVActivityIndicatorView#defaults
}
}
我只是用更新的數據重新加載collectionView。 – toddg
唯一的問題是,我使用加載動畫,然後將顯示在舊的collectionView單元格,直到它重新加載。 – GarySabo
你的意思是像一個'UIRefreshControl'?發佈一些你的代碼,以便我可以得到一個更好的主意。 – toddg