У меня возникла проблема с добавлением элементов в NSMutableArray
и написанием их в tableView. После этого кода он должен писать в элементах tableView от @ "0" до @ "19", но он показывает мне от 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
Переместить setText: метод снаружи (внизу внизу) (cell == nil). – EDUsta
@EDUsta работает! Спасибо! –