在UITableView上显示重新排序控件时启用“滑动到删除” [英] Enabling Swipe-to-delete while showing reorder controls on UITableView
问题描述
我希望允许重新排序 UITableViewCell
并通过滑动删除删除,但不能通过红色删除圈删除。
I am looking to allow reordering of UITableViewCell
s and deleting via swipe to delete, but not via the red delete circle.
- (void)loadView
{
[super loadView];
[table setEditing:YES animated:NO];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Perform delete here
}
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
// Perform move here
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
此外,我尝试禁用编辑模式并调用 - [UITableViewCell setShowsReorderControl:YES]
没有运气。
Additionally, I've tried disabling the edit mode and calling -[UITableViewCell setShowsReorderControl:YES]
with no luck.
图片http://booleanmagic.com/uploads/ReorderNotDelete.png
推荐答案
我认为你必须做一些自定义触摸事件拦截。
I think you'll have to do some custom touch event interception.
英文:
如果手指移动,x距离,水平跨越单元格,仅在该单元格中,然后显示删除控件。
In english: if finger moved, x distance, horizontally across cell, in that cell only, then show delete control.
不知道如何关闭左边的圆圈,但我确实认为这是显示重新排序控制的属性
Not sure how to turn off the circles to the left, but I do think it's a property like "shows reorder control"
这篇关于在UITableView上显示重新排序控件时启用“滑动到删除”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!