How to change iPhone UITableView delete button title while editing it
You can change it in UITableView delegate method
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
Change delete button title in UITableView editing mode
This is easily done using the proper UITableViewDelegate
method:
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"CustomLabel";
}
How to change uitableview delete button text
In your controller managing the UITableView
you should implement the UITableviewDelegate
and return the title you want for your method inside the titleForDeleteConfirmationButtonForRowAtIndexPath
method.
Example:
@interface CategoryAddViewController : UITableViewController
@end
@implementation CategoryAddViewController
// ...
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"Please don't delete me!";
}
@end
Leaving you off with something like that:
Custom Delete button On Editing in UITableView Cell
luvieere is right -- if you want that same "delete" metaphor, you want to keep it at the red button that Apple provides. Why change it? Its globally recognizable as the standard for delete buttons.
Although, if you want something like Tweetie, where you completely change the behavior of swiping, you could use something like ABTableViewCell where you just draw in your own view. Make a custom table view, override -touchesBegan:withEvent:, and check for touches. Calculate the delta of the two touches (in touchesMoved:withEvent:) and move your own view around.
Renaming the Delete button in edit mode of tableviewcontroller
The UITableView delegate just has to implement:
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
Is there any way to change DELETE button from UITableViewCell?
To get this working, implement the following two methods on your UITableView's delegate to get the desired effect
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
// you need to implement this method too esle nothing will work:
}
check your method you created the name of UITableViewRowAction *viewAction but you returned teh value of callAction modify once and try
- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewRowAction *callAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Follow" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
NSLog(@"View Action fired");
}];
callAction.backgroundColor = [UIColor clearColor];
return @[callAction];
}
In Standard UITableViewRowAction
we can't change , we can change only
style
title
backgroundColor
backgroundEffect
for more information see the Apple Documents
How to change the default delete button in a table view cell in Swift?
swift tableview delegate have new method. Try this may be it will resolve your problem.
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?{
let ackAction = UITableViewRowAction(style: .default, title: "Himanshu", handler: myFunction)
ackAction.backgroundColor = UIColor.orange
return [ackAction]
}
Now you can even modify your delete functionality
Related Topics
iOS 11 - Unable to Change Navigation Bar Height
Xcode 9 Crash When Open Storyboard
Remove Uiwebview's Internal Cache
Xcode5 Simulator: Unknown Option Character 'X' In: -Xlinker
What Is the Use of Singleton Class in Objective-C
Does the List in Swiftui Reuse Cells Similar to Uitableview
Ble Device Keep Connect with iPhone When Application Terminate
Enabling Facebook Breaking Changes Feb 2013: Login Does Not Work
Dequeuereusablecellwithidentifier:Forindexpath: VS Dequeuereusablecellwithidentifier:
How to Take Uiimage of Avcapturevideopreviewlayer Instead of Avcapturephotooutput Capture
Declaring Global Variables in Swift
Downcast from Any to a Protocol
Xcode 7 Beta 6, Dyld _Nsarray0_ Crash
Fbsopenapplicationerrordomain Code=3
What Is Difference Between Self.Timer = Nil VS [Self.Timer Invalidate] in iOS