Не могу установить UITableViewCell detailTextLabel.text - PullRequest
4 голосов
/ 09 сентября 2011

DetailTextLabel не отображается соответственно, хотя источник там.Тем не менее, textLable.text отображается соответственно.

- (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 listDic

listDic:{
    Address = myAddress;
    Description = myDescription;
}

Ответы [ 2 ]

10 голосов
/ 09 сентября 2011
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];

Вам необходимо использовать initWithStyle: UITableViewCellStyleSubtitle

0 голосов
/ 13 ноября 2016

Swift (3)

let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "cellIdentifier")
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...