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

  • SEARCH
  • Home
  • 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 9162389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:12:05+00:00 2026-06-17T14:12:05+00:00

I have a strange problem when tapping a single UICell in UICollectionView and then

  • 0

I have a strange problem when tapping a single UICell in UICollectionView and then scrolling down or up in the UICollectionView I see that more one cell is selected. The other cells that are selected that were not tapped seem to be randomly selected throughout the UICollectionView layout. I have 3 columns of cells and many rows in the UICollectionView.

In my code I have the following:

- (void)collectionView:(UICollectionView *)myCV didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    LogInfo(@"Item Selected");
    // highlight the cell user tapped on
    UICollectionViewCell  *cell = [myCV cellForItemAtIndexPath:indexPath];
    [cell.layer setBorderWidth:10.0f];
    cell.layer.borderColor = [UIColor colorWithRed: 108/255. green: 166/255. blue: 16/255. alpha:1.0].CGColor;
    cell.layer.CornerRadius = 10;

}

The highlight code just puts a border on the tapped cell.

Is there a way to make sure that only the cell that is tapped is selected?

  • 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-17T14:12:06+00:00Added an answer on June 17, 2026 at 2:12 pm

    Its because cells can be re-used right? thats why you are getting this result.

    Solution is

    1. Save the selected indexpath at somewhere.

    2. Subclass your cell from UICollectionViewCell, then override UICollectionViewCell’s prepareForReuse method, there you have to reset from all the formatting you have done (in didSelectItemAtIndexPath method) to their default values and make the cell ready to use again. More about prepareForReuse is here

    3. Apply the same formatting again in cellForRowItemAtIndexPath to selected cell which indexpath you have saved first. thats it!

    But finally, I would suggest that don’t do any cell formatting kind of things directly here. Try to understand UICollectionViewLayoutAttributes and use it to do these kind of stuff there.

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

Sidebar

Related Questions

I have a strange problem on ipv6 connection. I write down a simple client
I have a strange problem getting the color of the point that was touched.
I have strange problem. I have own remote repository and upload their plugin. Then
I know that this question has already been asked, but I have strange problem
I have a strange problem when deleteting records using linq, my suspicion is that
Have a strange problem in that I have a Rake task that seems to
I have a strange problem that I've never encountered before, I have data in
I have a strange problem that I can't get my head around: I have
I have strange problem. When I use @return Model\Article in the model-loading method then
I have a strange problem that's happening with my WCF REST service. For an

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.