There is an array of 119 elements. I load into the tableview. As a result, only 14 items are loaded. There are no errors.

dataArray = [NSMutableArray arrayWithArray:arr]; - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [dataArray count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString*cellid=@"Cell"; UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:cellid]; if(cell==Nil){ cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid]; } cell.textLabel.text=[dataArray objectAtIndex:indexPath.row]; return cell; } 

    1 answer 1

    The problem is that the cells in the table are reusable .

    Here is what is written in the documentation :

    Table view: cellForRowAtIndexPath: should be always reuse a cell.

    You must reset the cell data, for example:

      if(cell == nil) { cell = [[UITableViewCell alloc]initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cellid]; } else { cell.textLabel.text = nil } cell.textLabel.text=[dataArray objectAtIndex:indexPath.row]; 
    • Got an empty table inserted this code - vlad_22de
    • f (cell == nil) {cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cellid]; } else {cell.textLabel.text = nil; } return cell; } - vlad_22de
    • An empty table is because cell.textLabel.text = nil, insert your values ​​cell.textLabel.text = [dataArray objectAtIndex: indexPath.row]; - Orest Mykha
    • Of course, it will be empty;) You must, after you have done the data reset, put your own. Just add to your else's code from the answer - Vitali Eller
    • Completed the answer to make it clearer - Vitali Eller