dimanche 10 mai 2015

IPhone/iPad: App Crash when Images Display on CollectionView while images are fetching from url

UICollectionView received memory warning when images are load & i'am using SDwebimages for fetching images.

My code :

 (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    Drinks *drink = [self.allDrinks objectAtIndex:indexPath.item];
    NSString *drinkImage;  
    drinkImage = [NSString stringWithFormat:@"http://ift.tt/1bHFmy4",drink.drinkid];}

    UIImageView *imageView    = (UIImageView *)[cell viewWithTag:2];

    [imageView setImageWithURL:[NSURL URLWithString:drinkImage] placeholderImage:[UIImage imageNamed:@"logo_black"]];

    [cell.contentView addSubview:imageView];
 }

App crash & received low memory warning.

i read UICollectionView received memory warning while scrolling.

Aucun commentaire:

Enregistrer un commentaire