How to add Custom EditingAccessoryView for UITableView?

I want to add a custom EditingAccessoryView to the cell, when the user swipe the delete button, I want to show my custom view.

+4
source share
2 answers

Constructive view from xib as an example below

alt text

now make an IBOutlet from uiview in the .h file

IBOutlet UIView *accessoryView; 

Connect this IBOutlet to your design presentation.

now in the .m file this view is set as editAccessoryView table cell

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; cell.editingAccessoryView = accessoryView; } } - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return NO; } 

now when scrolling your custom view, instead of the delete button will be displayed

-1
source

There is no function for this. All you can do is provide custom text for the delete confirmation button using the following function.

 - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath 
+2
source

All Articles