2017-01-09 7 views
-1

Я пытаюсь загрузить некоторые данные из массива в tableView, но загружается только изображение. там код:Объективные данные c не загружаются в таблицуView

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 


    CarsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 
    if(cell == nil){ 
     cell = [[NSBundle mainBundle]loadNibNamed:@"CarsTableViewCell" owner:self options:nil][0]; 
    } 

    cell.imageCar.image = [UIImage imageNamed:[[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"logo"]]; 
    return cell; 
    cell.lblName.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"name"]; 
    cell.lblHP.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"horse_power"]; 
    cell.lblPrice.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"price"]; 

} 

что я пропустил?

+0

Пожалуйста, верните ячейку; этот код напишите последний из метода cellForRowAtIndexPath. – Mohit

ответ

2

Ваша линия return cell; перед назначением любого текста на их ярлыки. Переместите эту строку в место после назначения текста.

0

Перенести строку кода return cell; от:

cell.imageCar.image = [UIImage imageNamed:[[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"logo"]]; 
return cell; 
cell.lblName.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"name"]; 

к:

cell.imageCar.image = [UIImage imageNamed:[[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"logo"]]; 
cell.lblName.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"name"]; 
cell.lblHP.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"horse_power"]; 
cell.lblPrice.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"price"]; 
return cell; 

Это решит проблему.

0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 


CarsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 
if(cell == nil){ 
    cell = [[NSBundle mainBundle]loadNibNamed:@"CarsTableViewCell" owner:self options:nil][0]; 
} 

cell.imageCar.image = [UIImage imageNamed:[[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"logo"]]; 
return cell; 
cell.lblName.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"name"]; 
cell.lblHP.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"horse_power"]; 
cell.lblPrice.text = [[_arrayCars objectAtIndex:indexPath.row]objectForKey:@"price"]; 

return cell; 

}