您的位置:首页 > 移动开发 > IOS开发

IOS学习之——向cell表格里面填数据

2016-04-20 19:47 591 查看
向表格中增加数据
方式一
: reloadData 刷新 tableView
方式二
: insertRowsAtIndexPath 只更新一部分
注意:没有多线程是
第二种方式性能低

//添加城市数据
City *city = [[City alloc]init];
city.name = @"深圳";
city.population = 3400;
//应该把城市对象 添加到 城市对象数组中
[self.allcities addObject:city];

//方式一
//    //刷新 整个 tableView
//    [self.tableView reloadData];

//方式二
//刷新 最后一行  保证要插入的数据已经插入到数据数组中
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:self.allcities.count - 1 inSection:0];
[self.tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationLeft];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: