ios - UICollectionView load items on top - load more option -


i building message app meteor-ios, going great i'm trying make load more feature can't maintain/save position of scroll view(when scroll top want load more items keep scroll view in same position before insert)

my code:

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 = self {                      this.collectionview!.insertitemsatindexpaths([newindexpath!])                  }                 })         )     }     else if type == nsfetchedresultschangetype.update {         self.blockoperations.append(             nsblockoperation(block: { [weak self] in                 if let = self {                       this.collectionview!.reloaditemsatindexpaths([indexpath!])                 }                 })         )     }     else if type == nsfetchedresultschangetype.move {          self.blockoperations.append(             nsblockoperation(block: { [weak self] in                 if let = self {                     this.collectionview!.moveitematindexpath(indexpath!, toindexpath: newindexpath!)                 }                 })         )     }     else if type == nsfetchedresultschangetype.delete {          self.blockoperations.append(             nsblockoperation(block: { [weak self] in                 if let = self {                     this.collectionview!.deleteitemsatindexpaths([indexpath!])                 }                 })         )     }    }   self.collectionview!.performbatchupdates({ () -> void in             operation: nsblockoperation in self.blockoperations {                 operation.start()             }             }, completion: { (finished) -> void in                 self.blockoperations.removeall(keepcapacity: false)           }) 

i'm using core data , meteor-ios. know can do? tried how set uitableview's scroll position previous location when click "load earlier items" button many other without success :(

thank much!!

yep, made if statement between range 20-50 contentoffset.y. if between values call loadmore() once.

make bool value save isloadfinish , wait until cell update. if wouldn't loadmore() call multiple time.

for ux experience have save old contentoffset.y before calling loadmore() , reset after load.

i need improve lot, simple hack now.

good luck.


Comments