Reputation: 859
I currently have one detailTextLabel
value for every cell in my table, but I want it to have two, one for price and one for condition. This is how I currently have it set up:
// price of the item
cell.detailTextLabel.text = [NSString stringWithFormat:@"$%@", _matchCenterArray[indexPath.section][@"Top 3"][indexPath.row+1][@"Price"]];
cell.detailTextLabel.textColor = [UIColor colorWithRed:0/255.0f green:127/255.0f blue:31/255.0f alpha:1.0f];
I want condition to be a second detailTextLabel
with a different color than the price one, and sitting right under it. Is there any way to include a secondary detail, or will I have to use a custom UITableViewCell? If the 2nd option, how would I go about doing this?
Upvotes: 0
Views: 204
Reputation:
Personally I would subclass UITableViewCell and put whatever UILabels you need into it visually. You can then connect those two labels to the cell controller .h file as IBOutlets to allow you to manage them from the table view controller.
If you are using Storyboards and have a table view already plugged in, if you click on the prototype cell at the top (just once) and open the identity inspector you will see a category at the top "Custom Class". Once you write the code / design your custom cell you will put the class name you gave it in here to start using it. You will have to make sure that you set up the cell correctly in your cellForRowAtIndexPath:
method in your table view controller implementation.
This is illustrated by the gentleman in this video (skip to 8:40 for the subclassing of UITableViewCell). He might be doing things a different way round than some other people, but the general principle is the same. Video
Upvotes: 1
Reputation: 615
The easiest way to do this would be to add another label to the cells content view. The alternative to this would be to create your own UITableviewcell that has 3 labels insted of 2
Upvotes: 0