简体   繁体   English

以编程方式关闭UITableViewCell的“滑动删除”按钮/状态?

[英]Programmatically dismiss the “swipe to delete” button/state for UITableViewCell?

I'm working on an iPad app which has a UISplitView . 我正在开发一款带有UISplitView的iPad应用程序。 The root view of the split view is a UITableView . 拆分视图的根视图是UITableView When the split view is rotated portrait, the root view controller is displayed in a UIPopoverViewController (obviously this is standard practice). 当分割视图以纵向旋转时,根视图控制器显示在UIPopoverViewController (显然这是标准做法)。

The issue I'm having is, when iPad is in portrait rotation, if the user swipes to delete on the root view and then touches on the detail view, and then opens the root view again, the cell will still be in the same state showing the "delete" from the swipe gesture. 我遇到的问题是,当iPad处于纵向旋转时,如果用户在根视图上滑动删除然后触摸详细视图,然后再次打开根视图,则单元格仍处于相同状态显示滑动手势中的“删除”。 This is not the expected behavior. 这不是预期的行为。

Currently I am calling reloadData on the table view in viewDidDisappear (after super) in the root view, which has the desired end result. 目前我在根视图中的viewDidDisappear (超级之后)的表视图上调用reloadData ,它具有所需的最终结果。 Is there is a more efficient way to accomplish this? 有没有更有效的方法来实现这一目标?

You could alternatively end the editing mode of the UITableView (probably also in viewDidDisappear ). 您也可以结束UITableView的编辑模式(可能也在viewDidDisappear )。

self.tableView.editing=false;

Not sure if that's more efficient - more explicit perhaps. 不确定这是否更有效 - 或许更明确。

并为其制作动画:

[tableView setEditing:NO animated:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM