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];   //将表滑动到最后一行

  }

posted @ 2016-10-31 13:05  LZ每天进步一点点  阅读(161)  评论(0编辑  收藏  举报