
How to add Edit / Done button in UITableView with an action on click?

UITableview Edit done Button
To add " Edit / Done button " in UITableView add the given code in UIView Controller..
self.navigationItem.leftBarButtonItem = self.editButtonItem; //call an action on button Click self.editButtonItem.target = self; self.editButtonItem.action = @selector(editClicked:);

Or you can simple write the method
- (void)setEditing:(BOOL)editing animated:(BOOL)animate
this method is always get call, when Edit / done Button is clicked. In that case you need not to write ..
**self.editButtonItem.target = self;
self.editButtonItem.action = @selector(editClicked:);**
Simply add "self.navigationItem.leftBarButtonItem = self.editButtonItem;"
into the viewDidLoad method and write the given method... in .m file.
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animate
{
[super setEditing:editing animated:animate];
if(editing)
{
NSLog(@"editMode on");
}
else
{
NSLog(@"Done leave editmode");
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.