【发布时间】:2017-05-08 20:31:48
【问题描述】:
我有一个collectionView 从网络中提取数据,然后用户删除了一个对象,我想显示剩余的对象。由于过去的噩梦是删除索引中的对象并处理与网络版本同步的本地数据,我可以通过调用新的调用来获取新的网络数据(减去已删除的对象),因为它并没有那么多。话虽如此,就在仍然存在的collectionView 中显示新数据而言,最好的方法是什么?我有点想扔掉collectionView(带有旧数据)并添加一个新数据,但是没有这样的方法可以做这样的事情吗?或者只是刷新整个collectionViewController?试图在这里找出首选方法而不是 hack =)
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。
-
唯一的问题是我使用了加载动画,然后它会显示在旧的 collectionView 单元格上,直到它重新加载。
-
你的意思是像
UIRefreshControl?发布您的一些代码,以便我可以更好地了解。 -
是自定义库,上面添加了我删除对象时调用的函数
-
你知道我想得越多你是对的,我认为从旧的
collectionView到新的 (-1) 会很糟糕,但它确实不是t,我想我就这样处理吧。谢谢!
标签: ios swift uicollectionview