UITableView subtitle not appearing
I have this simple code:
- (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] autorel开发者_JS百科ease];
cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;
}
// Configure the cell...
NSString *subtitle = [NSString stringWithString: @"All about the color "];
cell.detailTextLabel.text=subtitle;
cell.textLabel.text = [authorList objectAtIndex: [indexPath row]];
return cell;
}
The problem is that my subtitle doesn't appear.What am i doing wrong.Please help.Thanks.
You'll have to choose another cell style, look at the documentation:
UITableViewCellStyleDefault
A simple style for a cell with a text label (black and left-aligned) and an optional image view. Note that this is the default style for cells prior to iOS 3.0.
What you want, I think, is:
UITableViewCellStyleSubtitle
A style for a cell with a left-aligned label across the top and a left-aligned label below it in smaller gray text. The iPod application uses cells in this style.
You can refer to the Table View Programming Guide for iOS chapter Table View Styles and Accessory Views to see an overview of the styles and what they look like.
精彩评论