新人求助,关于table view的这种蓝色的勾怎么做

解决方案 »

  1.   

    Cell上面添加一个图片
      

  2.   

    自定义一个cell,里面可以加上自己想要的button,给button添加图片
      

  3.   

    节省内存开销就CALayer
      

  4.   


    //选中行
    - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        cell.accessoryType = UITableViewCellAccessoryCheck;
    }
      

  5.   

    提供2种思路。
    第一种,自定义cell,上面放一张图片。
    第二种,使用系统的。代码如下:
    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        for (UITableViewCell *cell1 in [self.tableView visibleCells])
        {
            cell1.accessoryType = UITableViewCellAccessoryNone;  //遍历所有cell,Type置为空,这个很重要
        }
         UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
         cell.accessoryType = UITableViewCellAccessoryCheck;
    }
      

  6.   

    //选中行
      for (UITableViewCell *cell1 in [self.tableView visibleCells])
        {
            cell1.accessoryType = UITableViewCellAccessoryNone;  //遍历所有cell,Type置为空,这个很重要
        }
      

  7.   

    如果是需要系统样式的对勾可以通过设置 cell 的accessoryType 来实现
    如果需要自定义的样式,可以通过自定义一个UITableViewCell 。并重写cell的
    - (void)setSelected:(BOOL)selected animated:(BOOL)animated { }
    来实现
      

  8.   

     cell.accessoryType = UITableViewCellAccessoryCheck;