Tutorial :how can i put the second line in the table view cell in objective-c?



Question:

I am using the following code to add the next line in the same same but i am not getting the output.

cell.detailTextLabel.text= [self.dataArray1 objectAtIndex:indexPath.row];  

where dataarray1 is the following array.

self.dataArray1 = [NSArray arrayWithObjects:@"sugar :   1 teaspoon", @"salt  :   1 teaspoon",@"sugar  :   1 teaspoon", @"salt  :   1 teaspoon",@"sugar  :   1 teaspoon", @"salt  :   1 teaspoon",@"sugar :   1 teaspoon", @"salt  :   1 teaspoon",nil];  

how can i add the more content in the same cell of table view.


Solution:1

Have you tried using the UITableViewCellStyleSubtitle UITableViewCellStyle? I'm guessing that the style you're using might not support the detail text.


Solution:2

You have to set the style of the cell when you init it for it to show the detail text.

- (id)initWithStyle:(UITableViewCellStyle)stylereuseIdentifier:(NSString *)reuseIdentifier  

the style you are looking for is UITableViewCellStyleSubtitle


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »