im new to obj-c and coding in general but im catching on really quick. i've come here looking for some guidance. im not sure how to word my problem so i made some visuals
when i delete a cell from the tableVC, it deletes without issues.
when i delete a cell while in a search, it deletes without issues.
after i delete a cell while in search and end my search by hitting cancel, i get sent back to my mainVC but i have the delete toggle on the left side of the cells and i have no way of removing it.
#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];
}
}
Why don't you call
[tableView setEditing:NO];
when you press the cancel button?
I suppose that you call that function but with TRUE somewhen..
Regards.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.