2

I have tried following libraries for Image cache:

  • SDWebImage

  • UIImageView+AFNetworking

But still app getting Memory Warning, crashed and stuck while scrolling.

I have used UITableViewCell for display image.

Some of the images are 1.5 MB or more, So i am not sure whether this is the issue or anything else?

Please guide. Any efforts from your side will be appreciated.

EDIT:

I have UITableViewCell for load UICollectionViewCell in UITableView:

Code for UITableViewCell.

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

    HomeViewCell *cell = (HomeViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    if (cell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"HomeViewCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }

    NSArray *arr=[[arrPsots objectAtIndex:indexPath.row ] valueForKey:@"PostImage"];
    [cell setCollectionWithImageArray:arr];

    return cell;
}

Code for UICollectionViewCell.

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

    static NSString *cellIdentifier = @"ScrollCollectionCell";
    ScrollCollectionCell *cell = [collectionView1 dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];

    NSString *imgKey = (IS_IPAD?@"PostImage":@"PostImage");
    NSString *strImage=[NSString stringWithFormat:@"%@",[arrImages valueForKey:imgKey]];

    [cell.imgScroll setImageWithURL:[NSURL URLWithString:strImage] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

    if ([arrImages count]==1) {

        self.pageControllPostImg.hidden=TRUE;
    }
    self.pageControllPostImg.hidden=TRUE;
    self.pageControllPostImg.numberOfPages=[arrImages count];
    return cell;
}
iOS Dev
  • 195
  • 9
  • could u pls show code related to retrieving and showing image ? – Teja Nandamuri Jul 11 '16 at 15:09
  • As @TejaNandamuri said, we need to see some code. In the meantime, you might want to check [THIS](http://stackoverflow.com/questions/24177205/handling-download-of-very-large-images-with-sdwebimage) question of mine, and a related issue [HERE](https://github.com/rs/SDWebImage/pull/769) in the `SDWebImage` library itself. – n00bProgrammer Jul 11 '16 at 15:30
  • Do you use reusable cells? – Igor Jul 11 '16 at 18:25
  • Hi guys.. I have added code. Please check and let us know if any issue. – iOS Dev Jul 12 '16 at 08:02

1 Answers1

1

I had this problem in one project, where previous programmer create new cell every time and didn't use reusable cells.

Igor
  • 12,165
  • 4
  • 57
  • 73
  • I have added code after "EDIT" please see the code. – iOS Dev Jul 12 '16 at 08:03
  • try replace HomeViewCell *cell = (HomeViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"HomeViewCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } with HomeViewCell *cell = (HomeViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier forIndexPath:indexPath]; – Igor Jul 12 '16 at 10:01
  • i will appreciate your help in this regard. But still no improvement in any issue which is mentioned in question. – iOS Dev Jul 15 '16 at 08:34
  • Its random and comes from API. – iOS Dev Jul 15 '16 at 10:48
  • are u still have a problem? – Igor Jul 15 '16 at 11:22
  • Yes, but i think issue is due to image. – iOS Dev Jul 18 '16 at 13:56
  • Try to reduce size of images. Better way, of course, when server does it. – Igor Jul 18 '16 at 14:24
  • Thanks Igor for your reply :) – iOS Dev Jul 19 '16 at 07:55