Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can’t set UITableViewCell detailTextLabel.text

The detailTextLabel is not displayed out accordingly thought the source is there. The textLable.text is displayed accordingly though.

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

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

    }

    // Configure the cell...
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteListArray"] != nil) {
        NSArray *listArray = [NSArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteListArray"]];
        NSLog(@"listArray:%@", listArray);
        NSDictionary *listDic = [listArray objectAtIndex:indexPath.row];
        NSLog(@"listDic:%@", listDic);
        cell.textLabel.text = [listDic objectForKey:@"Description"];
        cell.detailTextLabel.text = [listDic objectForKey:@"Address"];
    }

    return cell;

}

NSLogs of listDic

listDic:{
    Address = myAddress;
    Description = myDescription;
}
like image 630
Gavin Avatar asked Dec 28 '22 14:12

Gavin


1 Answers

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

You need to use initWithStyle:UITableViewCellStyleSubtitle

like image 198
jussi Avatar answered Jan 17 '23 16:01

jussi