0

TableView をスクロールするたびに、主に最初の行で画像がめちゃくちゃになります。私は本当に何をすべきかわかりません。

コードは次のとおりです。

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"Cell";

    BarCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    [cell.activityFotoBar startAnimating];
    cell.activityFotoBar.hidesWhenStopped = YES;

   if(!cell){
       cell = [[BarCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
   }

    NSMutableDictionary *infoBar = [self.bares objectAtIndex:indexPath.row];
    NSString *nomeImagem = [infoBar objectForKey:@"foto"];

    NSURL *url = [NSURL URLWithString:nomeImagem];
    NSURLRequest *requestImagem = [NSURLRequest requestWithURL:url];
    [NSURLConnection sendAsynchronousRequest:requestImagem queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

        if(connectionError == nil){
            cell.imageViewImagemBar.image = [UIImage imageWithData:data];
            [cell.activityFotoBar stopAnimating];
        }

    }];


    cell.labelNomeBar.text = [infoBar objectForKey:@"nome"];
    cell.labelEnderecoBar.text = [infoBar objectForKey:@"endereco"];
    cell.labelAvaliacaoBar.text = [NSString stringWithFormat:@"Votos: %@", [infoBar objectForKey:@"votos"]];

    return cell;

}

前もって感謝します!

4

3 に答える 3