1. 程式人生 > >UITableView表檢視中資料的重新整理操作

UITableView表檢視中資料的重新整理操作

全部重新整理

[self.tableView reloadData];

修改、重新整理某個section,即陣列array中修改了某個session資料時,重新整理資料則使用該語句。

[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:session] withRowAnimation:UITableViewRowAnimationNone];

刪除某個section,即陣列array中刪除了某個session時,重新整理資料則使用該語句。

[self.tableView deleteSections:
[NSIndexSet indexSetWithIndex:session] withRowAnimation:UITableViewRowAnimationNone];

新增某個section,即陣列array中新增了某個session時,重新整理資料時則使用該語句。

[self.tableView insertSections:[NSIndexSet indexSetWithIndex:session] withRowAnimation:UITableViewRowAnimationNone];

修改、重新整理某個row,即陣列array中修改了某個row資料時,重新整理資料則使用該語句。

[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:session]] withRowAnimation:UITableViewRowAnimationNone];

刪除某個row,即陣列array刪除了某個row時,重新整理資料則使用該語句。

[self.tableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:session]] withRowAnimation:
UITableViewRowAnimationNone];

新增某個row,即陣列array新增了某個row時,重新整理資料則使用該語句。

[self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:session]] withRowAnimation:UITableViewRowAnimationNone];