Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cell.detailTextLabel.text not working... why

Using the following code I am getting the text.label but not the detailTextLabel.text. The NSLog is displaying correctly.

cell.textLabel.text = [eventLabels objectAtIndex:indexPath.row];  
cell.detailTextLabel.text = [eventFields objectAtIndex:indexPath.row]];  

NSLog(@"%@", [eventFields objectAtIndex:indexPath.row]);  

I also tried...

cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", [eventFields objectAtIndex:indexPath.row]];     

I have not had problems with this before. Any suggestions?

John

like image 831
user278859 Avatar asked Feb 27 '10 22:02

user278859


3 Answers

Make sure you're using an appropriate UITableViewCellStyle with this (anything but UITableViewCellStyleDefault should thus work). The cell's style is specified when you initialize it.

like image 117
jbrennan Avatar answered Oct 26 '22 19:10

jbrennan


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

if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                                   reuseIdentifier:CellIdentifier] autorelease];
}

Do remember to change to UITableViewCellStyleSubtitle

like image 29
Kamille Avatar answered Oct 26 '22 17:10

Kamille


If you choose style UITableViewCellStyleSubtitle , your detailTextLabel.text will show

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                               reuseIdentifier:CellIdentifier] ;

UITableView Source

like image 2
Erhan Demirci Avatar answered Oct 26 '22 18:10

Erhan Demirci