lakshmen
lakshmen

Reputation: 29064

How to insert more than one piece of a data into a single cell of UITableView

I am interested to know how to add more than one piece of data into one line of data into a cell of UITableView.

For example in the StopWatch of the Clock App in Iphone, they are able to have more than one piece of data.

Lap  Time     Total
1    00.01.5  00.01.5

Interested to know how to add three values into one cell at a time...

Upvotes: 0

Views: 154

Answers (3)

Martol1ni
Martol1ni

Reputation: 4702

You could either subclass UITableViewCell, or you could choose the "Custom" attribute on IB on the cell, and drag and drop labels, buttons, and whatever you want into the UITableViewCell. Set tags on each IBOutlet you create. Then you can do like this in tableView:cellForRowAtIndexPath

UILabel *yourLabel = (UILabel *)[cell viewWithTag:tag]; // Set your own tag and outlet.

From there you can customize it just how you want, without having to subclass it.

When that is said, the usual way is to subclass UITableViewCell. That way, you can have each cell store information, and add the IBOutlets as properties to the CustomTableViewCell as normal. Then you could add the information to the CustomTableViewCell, and let the cell take care of the rest.

Upvotes: 0

Asif Mujteba
Asif Mujteba

Reputation: 4656

You would have to create a custom uitableviewcell for that checkout this tutorial or refer to Apple Documentation for more detail

Upvotes: 1

Eli Ganem
Eli Ganem

Reputation: 1479

You'll need to create your own cell, which inherits from UITableViewCell. Here's an example of how to create your custom UITableViewCell.

Upvotes: 1

Related Questions