-(void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
}
When a user hits DELETE you can process it:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// If row is deleted, remove it from the list.
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// delete your data item here
// Animate the deletion from the table.
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
7 comments:
Hi there, can i ask a question ?
I wanna custom the text on delete button (incase swipe-to-delete), do you know how to do that?
Thanks in advance
thx for passing by!
If we don't talk here about localizations, then I think there is no any official way to do what you want. But you could try an unofficial one.
You know in the UITableViewCell there is a property _removeControl. You could try to use.
something like it is done here, I guess:
http://www.google.com/codesearch/p?hl=en&sa=N&cd=1&ct=rc#F7b37LddSXY/Mobile/Views/CQFileTransferTableCell.m&q=UITableViewCell%20_removeControl
http://www.google.com/codesearch/p?hl=en&sa=N&cd=1&ct=rc#F7b37LddSXY/Mobile/Views/CQFileTransferTableCell.h&q=UITableViewCell%20_removeControl
Anyway, since this will change standard behavior of the control it may be problematic to pass AppStore review.
BTW, tell me whether it works at all.
sorry, in the previous comment the links were truncated.
Just go to
www.google.com/codesearch
and search for
CQFileTransferTableCell.h
and
CQFileTransferTableCell.m
Thanks for the information Anar, it's really helpful and it WORK like charm.
Sorry because the late response cause i went out during last weekend. Just review those code that you provided, try to implements this morning and it work.
It's really nice and glad to meet you and i'm just coding for learning purpose so that i dont care much about AppStore's review.Beside i just change the label of Delete button incase swipe-to-delete, is that can be called change standard behavior of the control ? I didnt know where to find the list of AppStore review criteria.
Hope that i can keep in touch with you. If you're using skype then my skype id is huynvt83.
My name's Huy, from VietNam, sorry because of my bad English :)
Nice to see that it helped. ;)
Concerning AppStore review, I believe when I assigned to the iPhone developer program in the agreement it was mentioned that I must not used hidden API.
I think everything what starts with the underscore sign "_" in Cocoa is for Apple internal use only.
So, I am not really sure whether they accept this implementation or not. I just don't know. :(
I hope to see you next time on my blog ;) I don't have much time to post here, but I am going to update it time-to-time.
Update:
- Only work on iphone OS 2.2 or 2.2.1. I've upgrade my test device (iphone) to iphone OS 3.0 and the delete button has appear again without changing the label. So that i stuck here, searching for more information but nothing news till now.
- Also stuck with MapKit, searching for solution to develop with MapKit on iPhone OS 2.2 or 2.2.1 but i found out that MapKit framework does not include in iPhone SDK 2.2 (at least on iPhone simulator private framework)
As of iPhone OS 3 you can also use the following
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
Post a Comment