I added the "Edit" button to the navigation bar in my application.
I have a UIViewController that implements UITableViewDataSource and UITableViewDelegate.
I added a UITableView using the storyboard and made connections to the data source and delegation.
I liked this in the view controller implementation file:
self.navigationItem.rightBarButtonItem = self.editButtonItem; [self.editButtonItem setAction:@selector(setEditing:animated:)];
and
- (void)setEditing:(BOOL)editing animated:(BOOL)animated { DLog(@"Editing = %d", editing) NSLog(editing ? @"Yes" : @"No"); [self.recentSearchList setEditing:editing animated:YES]; }
The problem is that whenever I click the βEditβ button, the βEditβ variable of BOOL is always βYESβ. And for the first, it sets the UITableView mode to edit mode, but the Edit button still shows the Edit label instead of Finish. And since the parameter is always YES, the table view is never set to normal.
I read from the answer here: UITableView in edit mode - the "Edit" button does not change the status
I assume that the "Change" button should change its state when clicked. And the parameter in the overridden method should also switch.
I can write my own code to set the flags in the UIViewController to check the mode and switch the View table accordingly, but I assume there must be some other way.
source share