Saturday, June 8, 2013

UITableView tableView titleForDeleteConfirmationButtonForRowAtIndexPath example in Objective C (iOS).


UITableView tableView titleForDeleteConfirmationButtonForRowAtIndexPath

Changes the default title of the delete-confirmation button.

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath

Parameters of [UITableView tableView titleForDeleteConfirmationButtonForRowAtIndexPath]
tableView
The table-view object requesting this information.
indexPath
An index-path object locating the row in its section.

Return Value
A localized string to used as the title of the delete-confirmation button.

Discussion of [UITableView tableView titleForDeleteConfirmationButtonForRowAtIndexPath]
By default, the delete-confirmation button, which appears on the right side of the cell, has the title of “Delete”. The table view displays this button when the user attempts to delete a row, either by swiping the row or tapping the red minus icon in editing mode. You can implement this method to return an alternative title, which should be localized.

UITableView tableView titleForDeleteConfirmationButtonForRowAtIndexPath example.
@interface CategoryAddViewController : UITableViewController <UITableViewDelegate>
@end

@implementation CategoryAddViewController
// ...
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"Please don't delete me!";
}

@end

Example of [UITableView tableView titleForDeleteConfirmationButtonForRowAtIndexPath].

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return @"Close";
}

UITableView tableView titleForDeleteConfirmationButtonForRowAtIndexPath example.
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return @"Cancel";
}

End of UITableView tableView titleForDeleteConfirmationButtonForRowAtIndexPath example article.