How to Change iPhone Uitableview Delete Button Title While Editing It

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:

Sample Image

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



Leave a reply



Submit