#PRagma mark - 數(shù)據(jù)刷新操作- (IBAction)add { // 添加模型數(shù)據(jù) JXWine *wine = [[JXWine alloc] init]; wine.money = @"20.5"; wine.name = @"很好喝的酒"; wine.image = @"new_wine"; [self.wineArray insertObject:wine atIndex:0]; // [self.wineArray addObject:wine]; // 告訴tableView:模型數(shù)據(jù)改變了,趕緊刷新表格 [self.tableView reloadData];}- (IBAction)remove { // 刪除模型數(shù)據(jù) [self.wineArray removeObjectAtIndex:0]; [self.wineArray removeObjectAtIndex:0]; // 告訴tableView:模型數(shù)據(jù)改變了,趕緊刷新表格 [self.tableView reloadData];}- (IBAction)update {// JXWineCell *cell = (JXWineCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];// cell.detailTextLabel.text = @"¥100"; // 更改模型數(shù)據(jù) JXWine *wine = self.wineArray[0]; wine.money = @"100"; JXWine *wine2 = self.wineArray[1]; wine2.name = @"哈哈"; // 告訴tableView:模型數(shù)據(jù)改變了,趕緊刷新表格 [self.tableView reloadData];} #pragma mark - 數(shù)據(jù)刷新操作- (IBAction)add { // 添加模型數(shù)據(jù) JXWine *wine = [[JXWine alloc] init]; wine.money = @"20.5"; wine.name = @"很好喝的酒"; wine.image = @"new_wine"; [self.wineArray insertObject:wine atIndex:0]; JXWine *wine2 = [[JXWine alloc] init]; wine2.money = @"100.5"; wine2.name = @"很好"; wine2.image = @"new_wine"; [self.wineArray insertObject:wine2 atIndex:0]; // 刷新 NSArray *indexPaths = @[ [NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:1 inSection:0] ]; [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationRight];}- (IBAction)remove { // 刪除模型數(shù)據(jù) [self.wineArray removeObjectAtIndex:0]; [self.wineArray removeObjectAtIndex:0]; // 刷新 NSArray *indexPaths = @[ [NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:1 inSection:0] ]; [self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationMiddle];}- (IBAction)update { // 更改模型數(shù)據(jù) XMGWine *wine = self.wineArray[0]; wine.money = @"100"; XMGWine *wine2 = self.wineArray[2]; wine2.image = @"new_wine"; XMGWine *wine3 = self.wineArray[3]; wine3.image = @"new_wine"; // 局部刷新 NSArray *indexPaths = @[ [NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:2 inSection:0], [NSIndexPath indexPathForRow:3 inSection:0] ]; [self.tableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationLeft];}新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注