ios - UITableView删除编辑将单元格内容向右推送

标签 ios iphone uitableview coding-style editing

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

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

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

关于这个的另一个问题。有什么方法可以定义 indexPath.row == 0setEditing:TRUE 上没有删除图标?

最佳答案

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

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

关于ios - UITableView删除编辑将单元格内容向右推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5075807/

相关文章:

ios - 使用自动布局在 View 中居中 UI 元素

ios - 如何显示带有大标题的UITabbar

iphone - NSURLRequest 委托(delegate)未在设备上被调用在模拟器上工作正常。

iphone - "Blue box"显示在 iOS 应用程序中的自定义 UIButton 旁边

ios - Tableview 剪切了最后一行但返回后正确

iphone - 是否可以在没有 Storyboard的情况下在 Interface Builder 中创建原型(prototype)单元?

ios - value 不为零,但在解包可选值时意外发现 nil

ios - 使用 UIImagePickerController 将图像上传到服务器显示您尝试上传的文件类型是不允许的 (Swift/iOS)

ios - SpriteKit 在碰撞后保持恒定速度

ios - 在 iOS 中的自定义单元格上滑动删除