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;
}
最佳答案
detailTextLabel
不会为具有 UITableViewCellStyleDefault
样式的 cells
显示。 init
UITableViewCell
与 UITableViewCellStyleSubtitle
代替,您应该会看到您的 detailTextLabel
。
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
关于objective-c - 为什么 detailTextLabel 不可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5190648/