为什么detailTextLabel不可见?

Cha*_*har 55 objective-c cell uitableview detailtextlabel

detailTextLabel不可见(代码如下).你能告诉我为什么吗?

 // Customize the appearance of table view cells.
 - (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...

NSString *cellValue = [myListArray objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;

cell.detailTextLabel.text = @"Hello "; // This is not visible
cell.image = [myListArrayImages objectAtIndex:indexPath.row];

return cell;
}
Run Code Online (Sandbox Code Playgroud)

小智 128

detailTextLabel不显示cellsUITableViewCellStyleDefault风格. initUITableViewCellUITableViewCellStyleSubtitle替代,你应该看到你的detailTextLabel.

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


rei*_*man 26

或者,如果您使用的是Interface Builder,请将Stylecell属性更改为Subtitle.:)

Interface Builder中的样式单元属性.