Reputation: 3165
I'm using UITableViewCell.
I'd like to programatically change the UITableViewCell's mode from Delete to Edit when user is canceled delete.
Please let me know how to change.
Thank you for your help.
Here is trying code.
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
UITableViewCell *aCell;
aCell = [self tableView:gbl_tableView cellForRowAtIndexPath:gbl_indexPath];
if (buttonIndex == 0){
NSUInteger row = (NSUInteger) [gbl_indexPath row];
[userListStr removeObjectAtIndex:row];
[userImage removeObjectAtIndex:row];
[gbl_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:gbl_indexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
else if (buttonIndex == 1) {
// When user canceled.
[aCell setEditing:NO animated:YES]; <==== ??? I can't know how.. This code don't work.
}
}
from delete to edit ->
Upvotes: 0
Views: 112
Reputation: 2987
Is it possible aCell
is null/nil? I believe the proper way to pull the cell form the UITAbleViewController is something like:
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:nowIndex];
In your case it would be
UITableViewCell *cell = [gbl_tableView cellForRowAtIndexPath: gbl_indexPath];
Upvotes: 1
Reputation: 3368
Have you tried this method?
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
You can return UITableViewCellEditingStyleNone
Upvotes: 1