我有一个tableView,需要显示textlabeldetailtextlabel

但是未显示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];
      }

      NSMutableDictionary *d2 =[[NSMutableDictionary alloc]initWithDictionary:[autocompleteUrls objectAtIndex:indexPath.row]];

      cell.textLabel.text = [NSString stringWithFormat:@"%@",[d2 valueForKey:@"FLName"]];
      cell.detailTextLabel.text=@"Id";
      cell.textLabel.font=[UIFont boldSystemFontOfSize:12];
      cell.textLabel.numberOfLines=0;

      return cell;
}


但是detailtextlabel没有显示,为什么?

最佳答案

您使用UITableViewCellStyleDefault,但必须使用UITableViewCellStyleSubtitle

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

关于iphone - cell.detaillabel的文本未显示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15140064/

10-11 23:00
查看更多