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 9161811
In Process

The Archive Base Latest Questions

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

I have a UICollectionView added to a ViewController. The UICollectionView displays a grid of

  • 0

I have a UICollectionView added to a ViewController. The UICollectionView displays a grid of items with peoples names on each cell.
I would like to add search as you type functionality that will filter the UICollectionView as the user types in their name to a searchbar or UITextField on the ViewController so that it doesn’t scroll with the content in the UICollectionView.

Even though a few places I have read that UICollectionView is similar to UITableView I don’t see that implementing this filter/search functionality is the same in UICollectionView as it is with UITableView and need some help with it.

Does anyone have a good example of doing this search/filter as you type functionality with UICollectionView?

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

    I solved it by doing the following (hope it helps somebody else):

    I populate my UICollectionView from CoreData into an NSArray:

    self.allCVData = [context executeFetchRequest:fetchRequest error:&error];
    

    then add my NSArray to an NSMutableArray so that I can use that for filtering on the UICollection:

    self.filteredCVData =  [[NSMutableArray alloc] initWithArray:allCVData];
    

    Added a UITextField and called it searchField.

    Added a selector in viewDidLoad:

    [mytextfield addTarget:self action:@selector(textDidChange:) forControlEvents:UIControlEventEditingChanged];
    

    Added a method to accept changes in the UITextField:

    -(void) textDidChange:(id)sender
    {
    
        UITextField* searchField = (UITextField *) sender;
    
        if(searchField.text.length == 0)
        {
            self.isFiltered = FALSE;
            [self.filteredCVData removeAllObjects];
            [self.filteredCVData addObjectsFromArray:self.allCVData];
        }
        else
        {
            self.isFiltered = true;
            [self.filteredCVData removeAllObjects];
            self.filteredCVData = [[NSMutableArray alloc] init];
    
            LogInfo(@"Before Looping in allCVData Array.");
            for (OLPerson* person in allCVData)
            {
                NSRange firstnameRange = [person.firstname rangeOfString:searchField.text options:NSCaseInsensitiveSearch];
                NSRange surnameRange = [person.surname rangeOfString:searchField.text options:NSCaseInsensitiveSearch];
                if(firstnameRange.location != NSNotFound || surnameRange.location != NSNotFound)
                {
                    [self.filteredCVData addObject:person];
                }
            }
        }
    
        [self.collectionView reloadData];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UICollectionView displaying image thumbnails. Each Image View in the grid has
I have a UICollectionView which uses UICollectionViewDelegateFlowLayout . I've added a method which changes
I have a UICollectionView showing several items. I also have an edit button in
I have UICollectionView with UICollectionViewCell created in storyboard. I customized cell by adding to
I have a UICollectionView which I am trying to insert items into it dynamically/with
I have a UICollectionView. It scrolls horizontally, has only a single row of items,
I am trying to add content 'above' the top of my UICollectionView and have
I'm using UICollectionView to show grid based View in iPad. I have only 200
I have a UICollectionView with a custom cell subclassing UICollectionViewCell . And in the
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=

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.