披露三角未出现在我的UITableViewCell上

问题描述

| 如何在UITableViewCell上具有标签,但在其最右侧具有箭头? 这是我尝试的:
   } else if(indexPath.row == 1) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50,200,21)];
        label.text = @\"Select to change code\";
        label.tag = 1;
        label.textColor = [UIColor grayColor];
        cell.accessoryView = label;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
但这不起作用。我看到标签,但在单元格最右侧看不到箭头。     

解决方法

        尝试以下方法:
 else if(indexPath.row == 1) {
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50,200,21)];
    label.text = @\"Select to change code\";
    label.tag = 1;
    label.textColor = [UIColor grayColor];
    [cell addSubview:label];//i changed oonly this line 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
希望对您有帮助........ 编辑:(因为我无法发表评论。进行细微更改的原因是在您的原始代码中,您已将标签添加到单元格中,作为其的附件类型subView(有效地用标签覆盖了它),而在修改后的代码中,标签已正确添加为单元的单独子视图。     ,        您不能同时具有cell.accessoryType获得的定制附件视图和系统提供的视图。这个怎么样:
cell.textLabel.text =  @\"Select to change code\";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...