views:

394

answers:

2

Hello,

I want to display multiple column on UITableView.

For Example:

TableView

FName LName Age

----- ----- ---

Abby Michale 34

Thanks in advanced

Annpurna

A: 

Create a custom UIView subclass containing, say, three UILabel elements as subviews. Then set the cell's contentView property to this custom view.

Alex Reynolds
A: 

You can define a custom cell in IB, which will contain 3 labels and in function:

    - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

         static NSString *DetailCellIdentifier = @"DetailCell";

         UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:DetailCellIdentifier];

         if (cell == nil) {
            [[NSBundle mainBundle] loadNibNamed:@"DetailCell" owner:self options:nil];
                 }

        // setup your cell
     }

when you define the cell in IB give each label a tag, so when you need to put a text there you can retrieve it by tag like this:

        label = (UILabel *)[cell viewWithTag:NAME_TAG];
        label.text = myObject.name; 

and repeat this with other 2 labels. The tag is a unique number.

Put this code instead //setup your cell comment

Nava Carmon
I have created a custom UIView subclass named as "DetailCell" and add three label on it .Add above written code on the tableview of Employee Detail UIView subclass.Run it ,it does not show any label on tabelView.
Annpurna Mishra
If you create it in IB you're supposed to create a UITableViewCell, not a UIView.See this link for creating customized cells in detail:http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html
Nava Carmon