2016-02-24 24 views
1

我試着去填補我的單元格值與視圖模型類信號:設置圖像的細胞與無功可可

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

    cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; 

    if ([self.viewModel.dataArray count] >4){ 

    // Text 
    cell.titleLabel.text = [[self.viewModel.dataArray objectAtIndex:indexPath.row]valueForKey:@"title"]; 

     NSString *urlString = [[self.viewModel.dataArray objectAtIndex:indexPath.row] valueForKey:@"thumbnailImage"]; 

     NSLog(@"Called n times"); 
    // Image 
    [[[self.viewModel loadImageWithString:urlString] 
        deliverOn:[RACScheduler mainThreadScheduler]] 
        subscribeNext:^(UIImage* x) { 

         cell.myImageView.image = x; 
        }]; 

    } 


    return cell; 

} 

標題爲每個細胞充盈良好,正確顯示。但圖像僅爲最後一個單元格設置,並且它非常快速地閃爍5次(從jSON獲得的圖像數量),併爲最後一個圖像完成。

我錯過了什麼拼圖?

回答

2

使用'cell.myImageView.image = x''正在創建問題,尋找在indexpath中設置圖像的其他選項(從中獲取UITableViewCell)