-1
我有一个向NSMutableArray
添加元素并将它们写入到tableView中的问题。在这段代码之后,它应该从@“0”到@“19”的tableView元素中写入,但是它会显示我从0到13,然后以错误的顺序显示。NSMutableArray不要添加元素正确
下面是截图:
如何把它们写在正确的顺序排列的结束?
- (void)refreshBottom{
int p = 0;
for (int i = p; i< p + 20; i++) {
[cells addObject:@(i)];
}
[self.refreshControl endRefreshing];
[_timeline_table reloadData];
}
单元格是NSMutableArray
。
UITableView的数据源
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
[cell.textLabel setText:[NSString stringWithFormat:@"%@",[cells objectAtIndex:indexPath.row]]];
}
return cell;
}
发布你的'UITableViewDataSource'的代码。 – rckoenes
移动(cell == nil)情况下的setText:方法外部(向下)。 – EDUsta
@EDUsta的作品!谢谢! –