UITableViewDelegate.h
// Swipe actions
// These methods supersede -editActionsForRowAtIndexPath: if implemented
// return nil to get the default swipe actions
- (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView leadingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos);
- (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos);然而,我在我的trailingActions方法中返回零,我仍然可以在我的表视图中做一个完整的滑动来删除。我怎样才能防止整个刷卡?(我希望用户必须滑动,然后按下“删除”按钮。
@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
return nil
}编辑:我在canEditRowAt 11/XCode 9/Swift 4更新之前实现了iOS和提交编辑风格。甚至在我实现trailingSwipeActionsConfigurationForRowAt之前就启用了完整的滑动。
发布于 2017-09-26 02:39:40
执行如下:
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let delete = UIContextualAction(style: .destructive, title: "Delete") { (action, sourceView, completionHandler) in
print("index path of delete: \(indexPath)")
completionHandler(true)
}
let swipeAction = UISwipeActionsConfiguration(actions: [delete])
swipeAction.performsFirstActionWithFullSwipe = false // This is the line which disables full swipe
return swipeAction
}这是禁用完全滑动的行。
swipeAction.performsFirstActionWithFullSwipe = false 如果您实现任何类似editingStyle和editActionsForRowAt的函数,则删除其他函数。
发布于 2019-08-09 15:13:59
我能够通过以下答案禁用特定单元格的滑动操作:https://stackoverflow.com/a/50597672/1072262
您可以返回,而不是返回零:
return UISwipeActionsConfiguration.init()https://stackoverflow.com/questions/46414707
复制相似问题