Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionView显示重用时来自旧单元格的值_Ios_Objective C_Uicollectionview_Reuseidentifier - Fatal编程技术网

Ios UICollectionView显示重用时来自旧单元格的值

Ios UICollectionView显示重用时来自旧单元格的值,ios,objective-c,uicollectionview,reuseidentifier,Ios,Objective C,Uicollectionview,Reuseidentifier,我有一个UICollectionview,它是根据先前UIViewController中的serchbar结果加载的。在收集的单元格中,我从internet加载图像。调用collectionView:(UICollectionView*)cv cellForItemAtIndexPath:时,我会在单元格的图像上放置一个占位符,然后开始从internet下载图像。 下载完成后,我重新加载单元格,以便正确放置最终图像。因此,该方法对每个单元格调用两次 这是本准则中可能感兴趣的部分: - (TXCe

我有一个
UICollectionview
,它是根据先前
UIViewController
中的
serchbar
结果加载的。在收集的单元格中,我从internet加载图像。调用
collectionView:(UICollectionView*)cv cellForItemAtIndexPath:
时,我会在单元格的图像上放置一个占位符,然后开始从internet下载图像。 下载完成后,我重新加载单元格,以便正确放置最终图像。因此,该方法对每个单元格调用两次

这是本准则中可能感兴趣的部分:

- (TXCeldaPOICollection *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {


TXCeldaPOICollection *cell = [cv dequeueReusableCellWithReuseIdentifier:@"CeldaPOI" forIndexPath:indexPath];
...
       NSNumber *estaDisponible=[disponibles objectAtIndex:indexPath.row];
    if ([estaDisponible boolValue]==YES) {
        cell.imgCelda.image=[imagenes objectAtIndex:indexPath.row];
        NSLog(@"Imagen disponible en la celda numero numero %ld",(long)indexPath.row);
    } else {
        cell.imgCelda.image=[UIImage imageNamed:@"placeholder.png"];
        NSLog(@"Placeholder colocado en la celda numero numero %ld",(long)indexPath.row);
        // Monto la URL de descarga:
        NSString *urlDescarga=kBaseURL;

        urlDescarga=[urlDescarga stringByAppendingString:[[self.listaCeldas objectAtIndex:indexPath.row] valueForKey:@"foto1"]];
        NSURL *direccion=[NSURL URLWithString:urlDescarga];
        [self downloadImageWithURL:direccion conOrden:self.estadioFiltrado completionBlock:^(BOOL succeeded, UIImage *image, NSInteger ordenacion) {
            if (succeeded) {

                NSLog(@"Imagen descargada estadio %ld  orden %ld  indice %ld poi %ld@",self.estadioFiltrado, ordenacion, indexPath.row, [seleccionado.identificador integerValue]);

                if (ordenacion==self.estadioFiltrado) {
                    if (image!=nil) {
                        //Meto comprobacion de no rebase del array aunque genere algun error me protejo frente a cueelgues
                        NSInteger numeroImagenes= imagenes.count;
                        if (indexPath.row<=numeroImagenes-1) {

                            [imagenes replaceObjectAtIndex:indexPath.row withObject:image];
                            [disponibles replaceObjectAtIndex:indexPath.row withObject:[NSNumber numberWithBool:YES]];
                            NSArray *recargar=[[NSArray alloc] initWithObjects:indexPath, nil];
                             NSLog(@"Imagen DESCARGADA numero %ld y llamando a recargar ccelda",(long)indexPath.row);
                            [self.coleccion reloadItemsAtIndexPaths:recargar];
                        }
                    }
                }

            } else {

            }
        }];


    }
}
-(TXCeldaPOICollection*)collectionView:(UICollectionView*)cv cellForItemAtIndexPath:(NSIndexPath*)indexPath{
TXCeldaPOICollection*cell=[cv dequeueReusableCellWithReuseIdentifier:@“CeldaPOI”forIndexPath:indexPath];
...
NSNumber*estaDisponible=[disponibles objectAtIndex:indexPath.row];
如果([EstaDisposable布尔值]==是){
cell.imgCelda.image=[imagenes objectAtIndex:indexath.row];
NSLog(@“Imagen disponsible en la celda numero numero%ld”,(长)indexath.row);
}否则{
cell.imgCelda.image=[UIImage ImageName:@“placeholder.png”];
NSLog(@“占位符colocado en la celda numero numero%ld”,(长)indexath.row);
//蒙托·拉乌尔·德斯卡加:
NSString*urlDescarga=kBaseURL;
urlDescarga=[urlDescarga stringByAppendingString:[[self.listaCeldas objectAtIndex:indexath.row]valueForKey:@“foto1”];
NSURL*direccion=[NSURL URLWithString:urlDescarga];
[self-downloadImageWithURL:direccion conOrden:self.estadiofilterado completionBlock:^(BOOL成功,UIImage*图像,NSInteger或enacion){
如果(成功){
NSLog(@“Imagen descargada estadio%ld orden%ld indicie%ld poi%ld@”、self.estadiofilterado、ordenacion、indexPath.row、[seleccionado.identificador integerValue]);
if(ordenacion==self.estadiofilterado){
如果(图像!=nil){
//我对阵列不做任何调整,因为阿尔冈将军错误,我保护了一个朋友
NSInteger numeriomagenes=imagenes.count;

如果(indexPath.row如果您可以为搜索选择添加代码,您可能需要在从搜索栏中选择后显式重新加载集合视图searc栏位于以前的uiviewcontroller中,搜索结果显示在表格中,当选择其中一个时,我会推送一个新的控制器,在其中显示集合,因此事实上,我总是重新加载集合视图在搜索之后加载集合,因为我正在加载一个新的UIViewController。您是否尝试放置一个断点,以查看返回搜索结果时是否实际调用了dequeue方法?