Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

geiger10d

macrumors member
Original poster
Jan 31, 2011
57
0
hi im making a table view and i was wondering how to put a description of the table cell name directly under it and im not sure how to do that.

so something like this


(table cell)
BENCH PRESS
this exercise works your chest

etc
 
You can UITableViewCellStyleSubtitle for this. cell.textLabel.text is the title and cell.detailTextLabel.text is the subtitle in grey.

If this isn't what you want then you'll need to use a custom table view cell. You can look at the TableViewSuite sample code for examples of how to do that.
 
Code:
	if ([self.title isEqualToString:@"Chest Workouts"]) {
		switch (row) {
			case 0:
				cell.textLabel.text = @"Bench Press";
				cell.detailTextLabel.text = [NSString stringWithString:@"These are bench presses."];
				cell.textLabel.font = [UIFont systemFontOfSize:14]; //Change this value to adjust size
				cell.textLabel.numberOfLines = 2; //Change this value to show more or less lines.
				break;

it still doesnt work
 
Last edited by a moderator:
I think that you can't get multiline labels using the default table view cells. If you need that there's more that needs to be done and you need to use custom cells.
 
what this guy needs to do is just read the UITableView documentation, but probably is too lazy. So will post a snippet..

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
	
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:[B]UITableViewCellStyleValue1[/B] reuseIdentifier:CellIdentifier] autorelease];
    }
   
	cell.textLabel.text = @"Whatever u want";
	cell.detailTextLabel.text = @"Detail whatever u want";
	return cell;
}

They already told u to do this..
U can change the BOLD thing into others, which u have to change to ur likings, or just look for CustomTableViewCell..
 
thanks man i got it, and i changed it to subtitle, no i did read the documentation i knew i needed the subtitle but i just didnt know where to put it... but thanks for telling me where to change it!
 
hey Andrei Kirilenko ( who you look like) just because i said i did not read it before does not mean I would never read it... There really is no need for you to comment on this thread just to tell me that you did tell me where to put something... My bad i missed something... Not really cool to try to make me feel like a idiot

this guy just was more clear...
;)
 
just because i said i did not read it before does not mean I would never read it...
I'm confused. I thought you said you had read it.

There really is no need for you to comment on this thread just to tell me that you did tell me where to put something... My bad i missed something... Not really cool to try to make me feel like a idiot
I did not intend to make you feel like an idiot. I apologize if that's how it came across. I just wanted to point to specifically where the guide I directed you to helped you with your specific issue. I meant no harm.

this guy just was more clear...
If by "this guy" you meant "jnoxx" and all you are seeking from this forum is code you can copy-and-paste, then I will have to bow out of helping you in the future. Copy-and-paste is not programming. Good luck, though.
 
If by "this guy" you meant "jnoxx" and all you are seeking from this forum is code you can copy-and-paste, then I will have to bow out of helping you in the future. Copy-and-paste is not programming. Good luck, though.

Thanks for not putting me in a box oh godly moderator *bows down*
And yea, I shouldn't have done that.. But I remember the times when I began, I adored people like well, myself, who gave me snippets of code to go with.
So I have mixed feelings of how to handle these "situations" (omg i'm typing like this is a hostage situation).
So well. Thanks anyways, and i'd advise to stop bothering so much ;)
 
no man i was not just looking to copy and paste i was looking for where the command was to change it.... i would love for you NOT to "bow out of helping me in the future" we just had a miscommunication that is all.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.