2017-01-09 5 views
-1

arrayからtableViewにデータをロードしようとしていますが、唯一のイメージがロードされています。そこにコード:目的cデータがtableViewにロードされない

- (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

「return cell;」このコードは最後のcellForRowAtIndexPathメソッドを記述してください。 – Mohit

答えて

2

お客様のreturn cell;行は、ラベルにテキストを割り当てる前です。テキストを割り当てた後、この行を場所に移動します。

0
からのコード行 return cell;シフト

:それはあなたの問題を解決します

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; 

:に

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

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; 

} 
関連する問題