gpt4 book ai didi

ios - 添加自定义按钮后,将后退按钮添加回 navigationController

转载 作者:行者123 更新时间:2023-11-29 03:47:27 26 4
gpt4 key购买 nike

我正在尝试实现一个包含 uitableviewnavigationcontroller 。该表格 View 应该是可编辑的,并且要向表格添加行,用户应该按屏幕顶部栏上的加号按钮。但是,当我添加 uibarbuttonitem 并将其设置到左侧时,后退按钮不会重新出现?我该如何让它重新出现?

编辑按钮:

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

editButtonPressed 方法:

[_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];

editButtonDone 方法:

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

我是一个初学者,如果这很愚蠢,我很抱歉。

最佳答案

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

[[self navigationItem] setLeftBarButtonItem:nil animated:YES];

关于ios - 添加自定义按钮后,将后退按钮添加回 navigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17536512/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com