UITableView detailTextLabel - разработка для iphone - PullRequest
0 голосов
/ 23 июля 2011

почему «detailTextLabel» больше не работает?

- (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.
    cell.textLabel.text=[listData objectAtIndex:[indexPath row]];
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;


    cell.detailTextLabel.text=@"hi";
    return cell;
}

Ответы [ 2 ]

7 голосов
/ 23 июля 2011

Попробуйте изменить стиль ячейки, используйте этот код при инициализации ячейки

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

Для получения дополнительной информации о стилях ячеек см. Справочник по классу яблока

2 голосов
/ 23 июля 2011

Вы выбрали стиль ячейки UITableViewCellStyleDefault, который не поддерживает detailTextLabel

Попробуйте использовать другой стиль.

edit

Вы выбираете стиль в методе initWithStyle:reuseIdentifier;.Посмотрите документы UITableViewCell , в которых описаны доступные стили ячеек.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...