SCROLLING PROBLEM USING UICOLLECTIONVIEW IN XCODE?

Andrew Watson

Total Post:39

Points:273
Posted by  Andrew Watson
 753  View(s)
Ratings:
Rate this:

I have created an image gallery application using UICollectionView in iPhone. My collection view cell are approximately (65, 65) size. For our image gallery I am getting images using ALAssets from the ALAssetLibrary and storing them in a list(NSMutableArray). 

This is my code:

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
  static NSString *identifier = @"MyCell";
  UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
  UIView *parentView = [[UIView alloc] initWithFrame:CGRectMake(0,0, cell.frame.size.width, cell.frame.size.height)];
  UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,50,50)];
  imageView.image = [imageAssetList objectAtIndex:indexpath.row];
  [parentView addSubview:imageView];
  [cell addSubview:parentView];
  return mycell;
}

Now, my application running perfectly but whenever I will scroll image continuously I have getting scrolling problem, it will not scroll freely.
I google it but I don't get any perfect solution for that.
Please help me, how can I solve this problem.

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: Scrolling problem using UICollectionView in Xcode?

    I also faced the same problem in the UICollectionView, so I found the solution to scroll collection view perfectly. You can use this code:

    cell.layer.shouldRasterize = YES;
    cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
    for perfect result use above code under this code:
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier
    forIndexPath:indexPath];
    cell.layer.shouldRasterize = YES;
    cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
    I hope it will also solve your problem because this was helpful for me.

      Modified On Feb-04-2016 11:06:44 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!