【问题标题】:Custom UITableViewCell delete button not showing自定义 UITableViewCell 删除按钮未显示
【发布时间】:2013-06-27 10:52:37
【问题描述】:

我创建了一个自定义 UITableViewCell 子类,其中包含多个字段和一些其他属性。由于我在 UITableViewController 中使用了这个新单元格,因此单元格不会对“滑动删除”手势做出反应。

为了测试我的委托中是否缺少某些内容,我向我的 xib 添加了一个普通的标准 UITableView,连接了 dataSource 和委托,并从 -tableView:cellForRowAtIndexPath: 返回了一个常规 UITableViewCell,这再次启用了手势。

我在网上搜索,有人建议直接实施-layoutSubviews,但也没有用。

有什么我必须在我的子类中实现的吗?

【问题讨论】:

    标签: uitableview swipe-gesture


    【解决方案1】:

    经过数小时的搜索,在互联网上没有找到任何东西,我进行了一整天的反复试验,发现在我的 XIB 中,Editing 被设置为 Multiple Selection During Editing。

    我不知道这会禁用“滑动删除功能”。

    因为我需要两种可能性(s2d 除非编辑和编辑时多选)我在-toggleEditing: 方法中添加了这两行:

    if(![_tableView isEditing]) {
        [_tableView setAllowsMultipleSelectionDuringEditing:YES];    // <----
        [_tableView setAllowdSelectionDuringEditing:YES];            // <----
        [_tableView setEditing:YES animated:YES];
    }
    else {
        [_tableView setAllowsMultipleSelectionDuringEditing:NO];     // <----
        [_tableView setAllowdSelectionDuringEditing:NO];             // <----
        [_tableView setEditing:NO animated:YES];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-02
      • 1970-01-01
      • 2011-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多