我建立消息應用程序與流星 - 的iOS,一切都會很好,但我試圖使負載更多的功能,但我不能維護/保存滾動視圖的位置(當我滾動到頂部我要裝入多個項目,但保持在相同的位置滾動視圖插入前)UICollectionView加載頂部的項目 - 加載更多的選項
我的代碼:
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
if type == NSFetchedResultsChangeType.Insert {
self.blockOperations.append(
NSBlockOperation(block: { [weak self] in
if let this = self {
this.collectionView!.insertItemsAtIndexPaths([newIndexPath!])
}
})
)
}
else if type == NSFetchedResultsChangeType.Update {
self.blockOperations.append(
NSBlockOperation(block: { [weak self] in
if let this = self {
this.collectionView!.reloadItemsAtIndexPaths([indexPath!])
}
})
)
}
else if type == NSFetchedResultsChangeType.Move {
self.blockOperations.append(
NSBlockOperation(block: { [weak self] in
if let this = self {
this.collectionView!.moveItemAtIndexPath(indexPath!, toIndexPath: newIndexPath!)
}
})
)
}
else if type == NSFetchedResultsChangeType.Delete {
self.blockOperations.append(
NSBlockOperation(block: { [weak self] in
if let this = self {
this.collectionView!.deleteItemsAtIndexPaths([indexPath!])
}
})
)
}
}
self.collectionView!.performBatchUpdates({() -> Void in
for operation: NSBlockOperation in self.blockOperations {
operation.start()
}
}, completion: { (finished) -> Void in
self.blockOperations.removeAll(keepCapacity: false)
})
我使用的核心數據和流星IOS。那些人知道我能做什麼?我也試過how to set UITableView's scroll position to previous location when click "load earlier items" button任何其他許多沒有成功:(
非常感謝您!
你好,你解決了嗎? –