Home > DeveloperSection > Articles > Implementing UISearchBar in Table View

Implementing UISearchBar in Table View


iPhone iPhone  Ios  Objective C 
Ratings:
0 Comment(s)
 616  View(s)
Rate this:

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 more features in our previous sample. We will show country list in another view controller using table view controller and also we see how to implement SQLite database for our country list in our project.

 

To create the country list in Table view Controller follow the steps:

1.    As we already created a UIButton on main view controller, give it title as “Continue'.

 

2.    Now, goto file > new > file > select 'Objective-C class' and click on 'Next' button > in Class field enter 'SearchViewController', and select subClass as 'NSObject'.

 

3.    Now, select MainStoryboard.storyboard in project navigator and drag a view controller from object 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 from object 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'.

 

5.    Now, as previously create another Objective-C file and named it as 'CountryListViewController' after Finish, two file CountryListViewController.h and CountryListViewController.m file will be created in Project Navigator.

       

 

6.    Now, drag another view controller on MainStoryboard.storyboard and edit the class as 'CountryListViewController' and Storyboard ID as 'CountryListViewController', select the Navigation Item and give it title as 'Country List' using Attribute Inspector.

 

7.    Now, drag UISearchBar ('Search Bar and Search Display Controller') into CountryListViewController in storyboard. Set PlaceHolder of search bar as 'Search Country'. and also drag a Table view controller under the UISearchBar. (after it will look like this)

     

 

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

       

 

9.    Now, select project name from Project navigator > select Targets > select Summary > in Linked Frameworks and Libraries section click on + button and add 'libsqlite3.dylib'. It enables sqlite database in our project.

10.  Now, this is sufficient for this article, our designing 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:

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

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:

   

 

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


Don't want to miss updates? Please click the below button!

Follow MindStick