UITableView detailTextLabel - iphone开发

Dan*_*i A 0 iphone uitableview

为什么"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;
}
Run Code Online (Sandbox Code Playgroud)

Ara*_*han 7

尝试更改单元格的样式,在初始化单元格时使用此代码

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                                   reuseIdentifier:CellIdentifier] autorelease];  
Run Code Online (Sandbox Code Playgroud)

有关单元格样式的更多信息,请查看apple的类引用