繁体   English   中英

滑动以删除searcharray,将删除开关留在左侧

[英]swipe to delete searcharray leaves the delete toggle on the left

即时消息对obj-c和编码来说是新的,但即时消息赶上了。 我来这里寻求指导。 林不知道如何措辞我的问题,所以我做了一些视觉效果

当我从tableVC删除单元格时,它删除没有问题。

当我在搜索中删除单元格时,它会毫无问题地删除。

在删除搜索中的某个单元格并单击“取消”结束搜索后,我被发送回了mainVC,但是在单元格的左侧有删除开关,我无法删除它。

    #pragma mark Swipte cell to delete (see comment)
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

// bug: when deleting from search controller and ending search, VC does not end editing.
// todo: move this into the updateVC and make it a button to work around bug above (or just fix the bug you noob..)
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    if (editingStyle == UITableViewCellEditingStyleDelete){
        Contacts * contacts = [[Contacts alloc] init];
        if (tableView == self.searchDisplayController.searchResultsTableView){
            contacts = [listOfFilteredContacts objectAtIndex:indexPath.row];
            NSString* URL = [NSString stringWithFormat:@"removed website for security reasons", contacts.pidJSON];
            NSDictionary * dictionary = [JSONHelper loadJSONDataFromURL:URL];
            [listOfFilteredContacts removeObjectAtIndex:[indexPath row]];
        }
        else{
            contacts = [listOfContacts objectAtIndex:indexPath.row];
            NSString* URL = [NSString stringWithFormat:@"removed website for security reasons", contacts.pidJSON];
            NSDictionary * dictionary = [JSONHelper loadJSONDataFromURL:URL];
            [listOfContacts removeObjectAtIndex:[indexPath row]];
        }
        [tableView reloadData];
    }
}

你为什么不打电话

[tableView setEditing:NO];

当您按下取消按钮时?

我想您调用该函数,但有时使用TRUE。

问候。

暂无
暂无

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

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