Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9180699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:07:03+00:00 2026-06-17T18:07:03+00:00

I have a UICollectionView with a custom cell subclassing UICollectionViewCell . And in the

  • 0

I have a UICollectionView with a custom cell subclassing UICollectionViewCell. And in the code I have done the following:

 [self.collectionView_ registerClass:[AHPinterestCell class]
        forCellWithReuseIdentifier:@"AHPinterestCell"];

this is what goes in my cellForItem

  AHPinterestCell *cell =
                (AHPinterestCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"AHPinterestCell"
                                                                             forIndexPath:indexPath];

however, it seems that it’s not reusing the cell. In my collection view per screen it is showing about 9-10 cells, however when I do infinite scroll and then I call insertItemsAtIndexPath it calls the initWithFrame method on my custom cell, while it should probably reuse the cells I already have. Why is this?

EDIT:

I am adding a sample demo project that illustrates the problem, the link to the xcode project can be found here. It’s essentially doing an infinite scroll when you reach to the bottom, it just appends more stuff into it. But when you do so it’s going to call the init method again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:07:04+00:00Added an answer on June 17, 2026 at 6:07 pm

    In short, your code works fine. As expected, as cells scroll off the screen, they are eventually flagged as being available for reuse. And when you call dequeueReusableCellWithReuseIdentifier, if there is a cell available for reuse, it will do so. If not, it creates one.

    The time that you’ll see a lot of cells being created is if you scroll fast or continually. But if you do short little scrolls, let go, pause, let the UI catch up and repeat, then you’ll see very few cells being created.

    I interpret this as meaning that iOS prioritizes the UI and the creation of new cells over the dequeuing of old cells, allowing their reuse. So if you flip quickly, it has trouble catching up and flagging old cells as available for reuse. This is probably not altogether bad, as this is probably what gives collection views such smooth flow. Flagging old cells for reuse is one of the less important things for iOS to do here. But clearly if memory is tight, this might be a problem.

    By the way, if you put a NSLog in dealloc, too, you’ll notice that when the UI finally catches up after doing a really fast scroll through the collection view, it clearly has some logic that says “gee, I’ve got more spare cells than I really need, I’m going to get rid of some of these.” It’s a pretty clever implementation, actually. A focus on speed, but with some memory optimizations that take place once the UI quiets down.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a UICollectionView with custom UIViews for each cell. The UIView takes
I have UICollectionView with UICollectionViewCell created in storyboard. I customized cell by adding to
So my rootViewController contains a UICollectionView with a Custom UICollectionViewCell. I have a label
I have a UICollectionView that horizontally scrolls to show one UICollectionViewCell at a time.
I'm starting to experiment with custom UICollectionView layouts. I have a UICollectionView in my
We have a UICollectionView with a custom layout very similar to UITableView (it scrolls
I have a custom UICollectionViewCell subclass that overwrites initWithFrame: and layoutSubviews to setup its
I have a UICollectionView with some custom cells, it uses the flow layout and
I currently have implemented a UICollectionView with a UICollectionViewCell that does complete a segue
I have the following code in which I am trying to take each element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.