iOS_OC UITableView 知识点

1.插入新的数据并显示

  -(void)insertTableView:(Model *)model {

      NSMutableArray *indexPaths = [[NSMutableArray alloc] init];

      NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_dataSource.count inSection:0];  //创建新的NSIndexPath

      [indexPaths addObject:indexPath];  //增加到NSMutableArray中去

      [_dataSource addObject:model];    //UITableView 数据源更新数据

      [tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic];  //将新的行增加到表中

      [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];   //将表滑动到最后一行

  }

原文地址:https://www.cnblogs.com/lizhen24/p/6015508.html