---
title: "Scrolling problem using UICollectionView in Xcode?"  
description: "Scrolling problem using UICollectionView in Xcode?"  
author: "Anonymous User"  
published: 2016-01-28  
updated: 2016-02-04  
canonical: https://www.mindstick.com/forum/33938/scrolling-problem-using-uicollectionview-in-xcode  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# Scrolling problem using UICollectionView in Xcode?

I have created an [image gallery](https://www.mindstick.com/forum/12835/how-to-add-swipe-feature-to-a-image-gallery) [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) using UICollectionView in iPhone. My [collection view](https://www.mindstick.com/forum/33803/how-to-set-collection-view-cell-size-in-ios) cell are approximately (65, 65) size. For our image gallery I [am getting](https://www.mindstick.com/forum/34179/i-am-getting-error-while-assigning-the-data-to-the-array-list) images using ALAssets from the ALAssetLibrary and [storing them](https://www.mindstick.com/interview/34007/how-can-you-check-if-a-user-has-accepted-cookies-before-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](https://answers.mindstick.com/qa/94681/my-google-assistant-shows-completely-different-search-results-from-what-i-ask-how-can-i-solve-this-problem).

## Replies

### Reply by Tarun Kumar

I also faced the same [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) in the UICollectionView, so I found the solution to scroll [collection](https://www.mindstick.com/articles/1718/collections-in-java) 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.


---

Original Source: https://www.mindstick.com/forum/33938/scrolling-problem-using-uicollectionview-in-xcode

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
