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
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'.
Implementing UISearchBar in Table View 
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. 
      Implementing UISearchBar in Table View 

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)

      Implementing UISearchBar in Table View 

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

        Implementing UISearchBar in Table View 

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:

Implementing UISearchBar in Table View

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

Implementing UISearchBar in Table View

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 


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

  Modified On Dec-14-2017 01:32:58 AM

Leave Comment