我一直在努力调试这几个小时,而且我还没有在网上看到有同样问题的人。
我让删除功能按预期工作,然后在添加一些代码后,神秘地减去按钮停止运行。起初我以为他们根本没有工作,但后来发现,如果我按住我的水龙头大约5秒钟,它会转动并显示删除按钮。
桌面视图上有一些手势,但没有LongPress手势。单元格是自定义单元格,但是当我第一次使用它时,这不会导致问题。任何帮助表示赞赏。这是相关的代码:
///
/// Pushes detail view for item swiped
///
- (IBAction)cellSwipeLeft:(UISwipeGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateEnded && ![self isEditing]) {
NSIndexPath *gestureIndexPath = [self modelIndexPathForIndexPath:[self indexPathForUIGestureRecognizer:sender]];
// swiped left
}
}
///
/// Checks off reminder in list
///
- (IBAction)cellSwipeRight:(UISwipeGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateEnded && ![self isEditing]) {
NSIndexPath *gestureIndexPath = [self modelIndexPathForIndexPath:[self indexPathForUIGestureRecognizer:sender]];
//swiped right
}
}
- (IBAction)cellTap:(UITapGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateEnded && ![self.tableView isEditing]) {
NSIndexPath *gestureIndexPath =
[self modelIndexPathForIndexPath:[self indexPathForUIGestureRecognizer:sender]];
// push detail view
}
}
///
/// Makes tableview rows editable
///
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
///
/// Returns editing style of tableview
///
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
///
/// Toggles tableview editing
///
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[self.tableView setEditing:editing animated:animated];
}
///
/// Deletes selected rows
///
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self deleteReminderAtIndexPath:indexPath];
// Animate deletion
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[[self tableView] deleteRowsAtIndexPaths:indexPaths
withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
答案 0 :(得分:0)
我发现评论中建议的点按手势会导致问题。我通过将敲击手势设置为2次触摸来实现这一点,只是为了看看发生了什么。它按预期工作,所以他们一定是互相干扰。