Hello
I have a TableView on my View. I somehow do not have a Navigation bar. I only have UIButtons and I want one of my buttons to do exactly what the editButtonItem.
How must I proceed to do that?
Hello
I have a TableView on my View. I somehow do not have a Navigation bar. I only have UIButtons and I want one of my buttons to do exactly what the editButtonItem.
How must I proceed to do that?
add a target to that button – i.e.
@selector(editButtonPressed:)
Then in editButtonPressed: use the function
[self.tableView setEditing:YES animated:YES];
i think that'll work...
Where you create your button:
[myButton addTarget:self action:selector(toggleEditMode:) forControlEvents:UIControlEventTouchUpInside];
Then add the method:
-(void)toggleEditMode:(id)sender {
// Change the tableview's editing state to the opposite of the current state
[self.tableView setEditing:!self.editing animated:YES];
// change the title of the button
UIButton *editButton = (UIButton *)sender;
if (self.editing) {
[editButton setTitle:@"Done" forState:UIControlStateNormal];
} else {
[editButton setTitle@"Edit" forState:UIControlStateNormal];
}
}