I hav开发者_JAVA百科e two questions:
Can we change the tap event of the (-) minus sign that appears when the table is in editmode?
Can we change the image of the minus sign that appears when the table is in edit mode?
I tried to find the solution in various posts but failed. So if you know the solution in any other post kindly paste the link over here.
You can't change the minus sign image, but if you are using it to actually delete items then I would recommend that you keep it as it is anyway. The reason is that it is a well-known icon to iPhone users. If you want to represent delete in some other way, it may be potentially confusing.
That said, if you want the left button to represent something else, then you can create a custom table cell with an image on the left. That image can be anything you want then. You can display or hide the custom icon by overriding didTransitionToState:
Quoting Chris Carrett
You can't change the minus sign image, but if you are using it to actually delete items then I would recommend that you keep it as it is anyway. The reason is that it is a well-known icon to iPhone users. If you want to represent delete in some other way, it may be potentially confusing.
However if you really want to change the icon you could try to remove it and add your own UIImageView in place.
Update: I struggled with this but think I finally got it right.
I made a github repo as an example but this is the code hiding the old image:
- (void) removeOriginalEditControl{
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {
for (UIView *subsubview in subview.subviews) {
if ([NSStringFromClass([subsubview class]) isEqualToString:@"UIImageView"]) {
[subsubview removeFromSuperview];
break;
}
}
}
}
}
Check out the full example at: https://github.com/tiemevanveen/TableViewCustomEditControls
精彩评论