Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 126.96.36.199 release ready!
Owner and Founder. Opencart
Hello, in this blog we will learn how to add scopes in the search bar. By Default, UISearchController (i.e a view controller which displays search result based on the interaction with a search bar) only provide a text field for you. Adding Scopes provide you the features of filter the result based on certain conditions. Now, let’s start implementing scopes in UISearchController. We are going to create a list of Hogwarts Students and Filter them using Scopes on the basis of their Houses.
Firstly, Create an object of UISearchController in your ViewController.
Secondly, Extends the UISearchBarDelegate and UISearchResultsUpdating delegates in your View Controller.
Now, add the search bar of your UISearchController to your tableView Header.
Now, We need to provide the list for the scope and also we need to confirm the delegate of the search bar.
Finally, you need to override the selectedScopeButtonIndexDidChange methods. This method called when you select any option from the list shown in the scope. You can also get the current index of selected item via selectedScopeButtonIndex property of UISearchBar or via selectedScope parameter.
Now, When you click on searchbar you will see the scope list as shown in the below image.
Thank you for reading this article. If you want to read more articles regarding iOS Development click here or if you want to learn more about UISearchController then click here.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.