ARTICLE

How to Use Table in iPhone

Posted by Sachin Bhardwaj Articles | iOS October 29, 2012
In this article I will explain the process of creating a table in iPhone.
Reader Level:
Download Files:
 

Introduction

In this article I will create a Single View application and use the UITableViewController class. To add a UITableViewController class we do the following.

Select any one objective-C class and right-click on it then choose new file -> select objective C class -> click on next -> Choose subclass UITableViewController from the drop down list and enter whatever class name you want. If you want to use xib then you mark on it -> click on next -> select the location where you import the view controller class in the project.

In this article I use one button and one label on First view. When we click on the button we move to the table via navigation. After that when we click on any row of the table we move to UIView where I use an image view from XIB.

Step 1

Open XCode by double-clicking on it.

Select-xcode-in-iphone.jpg

Step 2

Create a New XCode Project via click on it.

create-project-in-iphone.jpg

Step 3

Now Select Single View Application and Click on Next.

single-view-application-in-iphone.jpg

Step 4

Now give your Product Name. Here I use TableView and Company Identifier Mcn Solutions and click on Next.

Project-name-in-iPhone.jpg

Step 5

Select the location where you want to save your project and click on Create.

save-project-location-in-iphone.jpg

Step 6 

Select ViewController.Xib class and right-click on it.

choose-new-file-in-iPhone.jpg

Choose New File..

Step 7

Select the Objective-C class.

Select-objective-c-class-in-iPhone.jpg

Step 8

Select Subclass of UITableViewController from the drop down list and give it the name DatatableViewController and click on the checkbox with xib to use the interface.

select-table-view-controller-in-iPhone.jpg

class-name-in-iPhone.jpg

Click on next.

Step 9

Now click on create to import the class to the project.

location-in-iPhone.jpg

Repeat those steps for adding the UIViewController class but use the name ImageViewController.

imageview-class-in-iPhone.jpg

Step 10

After that we select the imageviewcontroller class and add an image view on view from ImageViewController.Xib.

select-image-view-in-iphone.jpg

To add an image to UIImageView we select Image view Inspector.

add-image-in-iPhone.jpg

Step 11

Now select which Platform you want to see output for.

Run-in-iPhone.jpg

Output

Output 1 in iPhone:

output1-in-iPhone.jpg

Output 2 in iPhone:

output2-in-iPhone.jpg

Output 3 in iPhone:

output3-in-iPhone.jpg

Table view controllers are broadly used in iPhone application development. 

COMMENT USING