---
title: "Implementing UISearchBar in Table View"  
description: "In this article will implement some more features like- for country list we will use SQLite database and to display country list we will create new Vi"  
author: "Tarun Kumar"  
published: 2015-11-09  
updated: 2026-05-13  
canonical: https://www.mindstick.com/articles/11907/implementing-uisearchbar-in-table-view  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 3 minutes  

---

# Implementing UISearchBar in Table View

Previous article: PageViewController Sample using Storyboard\

Here we will continue where we finish our previous project, now we will implement some morefeatures in our previous sample. We will show country list in another [viewcontroller](https://www.mindstick.com/forum/33628/viewcontroller-s-viewdidunload-method-deprecated-in-ios-6) using table [view controller](https://www.mindstick.com/forum/33709/how-to-use-table-view-controller-with-small-sized-in-ios) and also we see how to implement [SQLite database](https://www.mindstick.com/articles/1554/crud-operation-in-asp-dot-net-using-sqlite-database) for [our country](https://answers.mindstick.com/qa/39160/why-is-modi-government-increasing-the-external-debt-of-our-country) list in our project.

##### To create the country list inTable view Controller follow the steps:

##### 1. As wealready created a UIButton on main view controller, give it title as

##### “Continue'.

##### 2. Now, gotofile > new > file > select 'Objective-C class' and click on 'Next'button >

##### in Class field enter 'SearchViewController', and select subClass as'NSObject'.

##### 3. Now, selectMainStoryboard.storyboard in project navigator and drag a view

##### controller fromobject library. Select newly created view controller, goto 'Identify

##### Inspector', in Class field select 'SearchViewController' from drop down. And in

##### Storyboard ID field name it as 'SearchViewController'.

##### 4. On'SearchViewController' storyboard, drag a UIButton and two UITextField

##### fromobject library, now select the UIButton and goto Attribute Inspector and give

##### it title 'Search Country'.

##### \
Same as select both text field and edit the Placeholder as'Code' and 'Mobile No'.

##### ![Implementing UISearchBar in Table View](https://www.mindstick.com/mindstickarticle/5df06757-6fa9-439c-8609-d2f5f52cb66c/images/66720e73-3860-4e34-adad-de1374847699.png)

##### 5. Now, aspreviously create another Objective-C file and named it as

##### 'CountryListViewController' after Finish, two file CountryListViewController.hand

##### CountryListViewController.m file will be created in Project Navigator.

##### ![Implementing UISearchBar in Table View](https://www.mindstick.com/mindstickarticle/5df06757-6fa9-439c-8609-d2f5f52cb66c/images/cad4eb5e-f45b-4f7f-9647-463ccbdbe282.png)

**6.** Now, draganother view controller on MainStoryboard.storyboard and edit the class as'CountryListViewController' and Storyboard ID as 'CountryListViewController',select the [Navigation](https://www.mindstick.com/blog/62/different-navigation-in-asp-dot-net) Item and give it title as 'Country List' using AttributeInspector.

\
**7**. Now, dragUISearchBar ('[Search Bar](https://www.mindstick.com/forum/315/how-to-achieve-similar-google-search-bar-functionality-in-c) and Search Display Controller') intoCountryListViewController in storyboard. Set [PlaceHolder](https://www.mindstick.com/forum/1519/how-do-i-remove-a-listbox-new-item-placeholder) of search bar as'Search Country'. and also drag a [Table view](https://www.mindstick.com/forum/34084/how-to-change-the-height-of-table-view-in-ios) controller under the UISearchBar. (after it will look like this)

![Implementing UISearchBar in Table View](https://www.mindstick.com/mindstickarticle/5df06757-6fa9-439c-8609-d2f5f52cb66c/images/204b4822-cdbb-4e17-bf12-09413e69bfc3.png)

8. Now,select 'Search Country' button in SearchViewController and press ctrl and clickand drag it into CountryListViewController, it created a segue. (like this)

![Implementing UISearchBar in Table View](https://www.mindstick.com/mindstickarticle/5df06757-6fa9-439c-8609-d2f5f52cb66c/images/73f21953-3e20-430e-892b-c40d66c1ba2e.png)

\
9. Now,select project name from Project navigator > select Targets > selectSummary > in Linked [Frameworks](https://www.mindstick.com/blog/11763/five-features-of-top-python-frameworks-for-web-developers-in-2018-that-make-everyone-love-it) and Libraries section click on + button andadd 'libsqlite3.dylib'. It enables sqlite database in our project.

10. Now, this is sufficient for this article, ourdesigning phase is completed.

\

Now, Run the project, here is the screen shots step by steps it looks like this:

This is the First Screen of our [application](https://www.mindstick.com/articles/12824/calculator-application-in-android):

\

![Implementing UISearchBar in Table View](https://www.mindstick.com/mindstickarticle/5df06757-6fa9-439c-8609-d2f5f52cb66c/images/ef844dbe-f697-4f8c-af87-d610875eaaed.png)\

\

when we click on 'Continue' button 'SearchViewController' will open:

\
![Implementing UISearchBar in Table View](https://www.mindstick.com/mindstickarticle/5df06757-6fa9-439c-8609-d2f5f52cb66c/images/66720e73-3860-4e34-adad-de1374847699.png)

when we click on 'SearchCountry' button it will open 'CountryListViewController', here you will see country name is not displaying here because we are not written any code for this page:

\

![Implementing UISearchBar in Table View](https://www.mindstick.com/mindstickarticle/5df06757-6fa9-439c-8609-d2f5f52cb66c/images/776881c7-0e60-498d-9f7f-0e7487aed6d2.png)

That's it, now you can Run the application by clicking 'Run' button on the top-left of the Xcode.

In our next article we will implement the code to display country list for our application.

Click the link for continue: Implementing Country List in TableView

---

Original Source: https://www.mindstick.com/articles/11907/implementing-uisearchbar-in-table-view

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
