ios - How to append items to the bottom of the table or collection view ? -
i have swift table view/collection view. there anyway append items end of container ? upside down stack or ?
you need insert rows @ in uitableview , collection view first need insert in data source. tableview
//update data source object need add [tabledatasource addobject:newobject]; nsinteger row = [tabledatasource count]-1 ;//specify row need add new row in case last nsinteger section = //specify section new row added, //section = 0 here since need add row @ first section nsindexpath *indexpath = [nsindexpath indexpathforrow:row insection:section]; [self.tableview beginupdates]; [self.tableview insertrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationright]; [self.tableview endupdates];
for collectionview
[self.mycollectionview performbatchupdates:^{ [collectiondatasource addobject:newobject]; nsinteger row = [collectiondatasource count]-1 ;//specify row need add new row in case last add new row in case last nsinteger section = //specify section new row added, //section = 0 here since need add row @ first section nsindexpath *indexpath = [nsindexpath indexpathforrow:row insection:section]; [self.mycollectionview insertitemsatindexpath: indexpath]; } completion:nil];
Comments
Post a Comment