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.te开发者_开发百科xt = [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
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.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
}
Do remember to change to UITableViewCellStyleSubtitle
If you choose style UITableViewCellStyleSubtitle
, your detailTextLabel.text
will show
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] ;
UITableView Source
精彩评论