【问题标题】:Swipeable table view cell with default action具有默认操作的可滑动表格视图单元格
【发布时间】:2015-06-24 23:43:36
【问题描述】:

iOS8 现在提供了一种使用操作创建可滑动表格视图单元格的方法。在 Apple 自己的邮件应用程序中,如果您一直拖动单元格,您还可以提交默认操作(邮件应用程序显示更多 | 标志 | 垃圾箱,如果您一直拖动并释放,则默认为垃圾箱)。有没有办法在 iOS 8 中做到这一点?

【问题讨论】:

  • 您指的是 Apple 的哪些应用程序?因此,我们可以准确了解您的意思。
  • 你说的是邮件应用是如何一路滑动的?
  • @BenKane Mail 应用程序 - 显示更多 |旗帜 |垃圾箱,如果您一直拖动并释放,它会执行垃圾箱操作。
  • @theMonster 是的邮件应用程序。
  • @Boon 不幸的是,这个功能是自定义的,不是内置的。

标签: ios uitableview ios8 swipe tableviewcell


【解决方案1】:

如果您指的是在 TableViews 上滑动删除,您可以使用以下代码:

//Enable multiple selections during editing
self.tableView.allowsMultipleSelectionDuringEditing = NO;

//Enable editing row
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return YES if you want the specified item to be editable.
return YES;
}

//Do something on delete
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
    //add code here for when you hit delete
}    
}

【讨论】:

    【解决方案2】:

    您要查找的内容尚未包含在公共 API 中。幸运的是,有人已经完成了这项工作:)

    JASwipeCell

    【讨论】:

      猜你喜欢
      • 2015-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多