Mitch1972
Mitch1972

Reputation: 69

Multiple Details on UITableView

i've got a simple question. How to set up an UITableView with multiple details. I've got plist where i'm storing all the details. This what I did for just one details.cell.textLabel.text = [[self.array objectAtIndex:indexPath.row] objectForKey:@"name"];

What to do if I want 2 details on my cell?

Many Thanks in advance.

Upvotes: 0

Views: 122

Answers (3)

Kent Robin
Kent Robin

Reputation: 2616

First off you need to set the type of cell you want, if you want a title plus detail you can do this:

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

then for setting the title and detail labels, just

[cell textLabel].text = @"some title"
[cell detailTextLabel].text = @"some detail text"

Upvotes: 1

Chris Mitchelmore
Chris Mitchelmore

Reputation: 6176

If your not happy with using cell.detailTextLabel and one of the provided styles(set up from storyboard) then one option would be to create a custom UITableViewCell.

You can either create a xib and drag and drop a cell in and customize it from there or if your only using 1 table it may be easier to use a prototype cell and customize it directly in your table. The key part is to create a new Class to support your cell.

Upvotes: 0

aahsanali
aahsanali

Reputation: 3547

you need to set style for the cell

have look into this guide

Upvotes: 0

Related Questions