Saturday, June 8, 2013

UITableViewCell detailTextLabel example in Objective C (iOS).


UITableViewCell detailTextLabel

Returns the secondary label of the table cell if one exists. (read-only)

@property(nonatomic, readonly, retain) UILabel *detailTextLabel

Discussion of [UITableViewCell detailTextLabel]
Holds the secondary (or detail) label of the cell. UITableViewCell adds an appropriate label when you create the cell in a style that supports secondary labels. If the style doesn’t support detail labels, nil is returned. See “Cell Styles” for descriptions of the main label in currently defined cell styles.

UITableViewCell detailTextLabel example.
    // 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"];
    }

Example of [UITableViewCell detailTextLabel].

cell.detailTextLabel.text = [NSString stringWithFormat:@\"This cell is in section: %i\", indexPath.section];

UITableViewCell detailTextLabel example.
cell.textLabel.text = [arrLocal objectAtIndex:2];
cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
cell.detailTextLabel.text = [arrLocal objectAtIndex:3];
cell.detailTextLabel.font = [UIFont systemFontOfSize:12];

End of UITableViewCell detailTextLabel example article.