UITableViewCell annexView不显示

我完全不确定为什么我的辅助视图不起作用。我只是希望一些文本出现在UITableViewCell的右侧(以及左侧),但仅显示左侧的文本。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

  UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@\"SwitchCell\"];

  if (cell==nil){
      cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@\"SwitchCell\"] autorelease];
      UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 60, 30)];

      cell.textLabel.text = @\"left text\";
      label.text = @\"right text\";

      cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

      cell.accessoryView = label;
      [label release];

  }
  return cell;
}
有任何想法吗?谢谢。     
已邀请:
        
cell.accessoryView = label;
您正在将AccessoriesView设置为标签,这样就不会看到任何公开指示器。如果要在单元格中显示标题和详细信息文本,请使用UITableViewCellStyleValue2像这样初始化它...
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@\"cellType\"] autorelease];
...然后像这样设置标题和详细信息...
cell.textLabel.text = @\"Title\";
cell.detailTextLabel.text = @\"Description\";
要了解不同的内置表格样式,请查看以下图片... 您可以调整textLabel和detailTextLabel以适合您的口味。     
        为什么这个?不能两者兼有。
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
        
-(id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier
在iOS 3.0中已贬值 而是使用:
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
传入
UITableViewCellStyleValue1
UITableViewCellStyleValue2
并根据需要设置
textLabel
detailTextLabel
属性。 http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html%23//apple_ref/doc/uid/TP40006938-CH3-SW34     
        UITableViewCellStyleValue2给了我一个怪异的风格。我认为最常用的样式是UITableViewCellStyleValue1(至少就我而言)。     
        还要记住:如果您有自定义的AccessoriesView,则会忽略annexType属性。因此,这行代码是多余的。     

要回复问题请先登录注册