【问题标题】:UITableView delete editing pushes cell content to the rightUITableView删除编辑将单元格内容推到右边
【发布时间】:2011-02-22 08:35:56
【问题描述】:

在 tableView 上设置 [self.tableView setEditing:TRUE]; 时,本机表格删除编辑图标出现在左侧。但是当使用普通样式的表格时,这些圆形图标会将我的行背景(和内容)推到右侧。

如何防止编辑样式改变我的单元格位置,而是将图标放在单元格顶部?

现在它看起来像一个错误。

关于这个的另一个问题。有没有办法将indexPath.row == 0 定义为在setEditing:TRUE 上没有删除图标?

【问题讨论】:

    标签: ios iphone uitableview coding-style editing


    【解决方案1】:
    1. 将单元格的shouldIndentWhileEditing 属性设置为NO
    2. 实现委托的tableView:editingStyleForRowAtIndexPath: 方法并从中返回适当的值,例如:

      - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
         if (indexPath.row == 0)
             return UITableViewCellEditingStyleNone;
         return UITableViewCellEditingStyleDelete;
      }
      

    【讨论】:

    • 谢谢! 2:工作完美! 1:完全没有效果。还尝试了 tableView:shouldIndentWhileEditingRowAtIndexPath 没有运气。有什么想法吗?
    【解决方案2】:

    好的,找到#1 不起作用的原因。我将我的行背景设置为 cell.contentView 上的视图,而不是将其放在 cell.backgroundView 上。这样,内置功能无法将背景与内容分开。

    shouldIndentWhileEditingRowAtIndexPath 函数只会阻止背景缩进,而不是内容,因为编辑图标必须有空间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-09
      • 2013-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多