0

I'm trying to implement a navigationcontroller that has a uitableview in it. This tableview should be editable, and to add rows to the table the user should press a plus button on the top bar on the screen. However, when I add a uibarbuttonitem and set it to the left side, the back button doesn't re-appear? how would i make it reappear?

The edit button:

UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editButtonPressed)];
[[self navigationItem] setRightBarButtonItem:button];

The editButtonPressed method:

[_actionList setEditing:TRUE];
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addAction)];
[[self navigationItem] setLeftBarButtonItem:addButton animated:TRUE];
editButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(editButtonDone)];
[[self navigationItem] setRightBarButtonItem:editButton animated:TRUE];
[self disableButtons];

The editButtonDone method:

[_actionList setEditing:FALSE];
editButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editButtonPressed)];
[[self navigationItem] setRightBarButtonItem:editButton];
[self enableButtons];

I'm a beginner so sorry if this is dumb.

4

2 回答 2

1

离开编辑模式时尝试重置左栏按钮。

[[self navigationItem] setLeftBarButtonItem:nil animated:YES];
于 2013-07-09T17:02:08.917 回答
0

尝试这个:

    [yourNavBar pushNavigationItem:self.navigationItem animated:NO];

希望能帮助到你

于 2013-07-08T21:52:39.957 回答