编辑完成时是否有“setEditing”的逆操作?

发布于 2024-08-18 17:53:25 字数 1057 浏览 1 评论 0原文

我正在开发一个传统的 iPhone UINavigationController 应用程序,带有自动后退按钮等。

我正在研究按下“编辑”按钮时的情况。左后退图标变暗,我的新图标出现,然后一旦我再次点击“编辑”按钮,后退按钮就会回来。

到目前为止,后退按钮消失了,我的新按钮进来了,但我无法将其放回去!我知道代码应该是什么,但我不知道在哪里调用它。

这是我到目前为止所拥有的:

 (void)setEditing:(BOOL)editing animated:(BOOL)animated {
   [self.navigationItem setHidesBackButton:editing animated:animated];   //fades back button

//de 006 - Load in Move section button here.
UIBarButtonItem *saveButton = [[[UIBarButtonItem alloc] 
                                initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
                                target:self action:@selector(altersection:)] autorelease];

self.navigationItem.leftBarButtonItem = saveButton;

基本上我想要 (void)setEditing:(BOOL)editingAnimated:(BOOL)animated { 的逆,我可以在其中执行以下操作:

self.navigationItem.leftBarButtonItem = nil;   //custom button hide
self.navigationItem.hidesBackButton = NO;      //replace back button 

是否有 的逆>(void)setEditing:(BOOL)编辑 ?

I'm working on a traditional iPhone UINavigationController app, with automatic back buttons etc.

I am working on when an 'edit' button is pressed. The LHS back icon dims, my new one comes in, and then once I tap the 'edit' button again, the back button comes back.

So far, the back button goes away, and my new one comes in, but I can't put it back! I know what the code should be, but I don't know where to call it.

Here is what I have so far:

 (void)setEditing:(BOOL)editing animated:(BOOL)animated {
   [self.navigationItem setHidesBackButton:editing animated:animated];   //fades back button

//de 006 - Load in Move section button here.
UIBarButtonItem *saveButton = [[[UIBarButtonItem alloc] 
                                initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
                                target:self action:@selector(altersection:)] autorelease];

self.navigationItem.leftBarButtonItem = saveButton;

Basically I want the inverse of (void)setEditing:(BOOL)editing animated:(BOOL)animated {, where I can do:

self.navigationItem.leftBarButtonItem = nil;   //custom button hide
self.navigationItem.hidesBackButton = NO;      //replace back button 

Is there an inverse of (void)setEditing:(BOOL)editing ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

阳光下的泡沫是彩色的 2024-08-25 17:53:25

不确定我完全理解这个问题:/

当您按下“完成”按钮时,我相信 setEditing 会再次被调用,但 NO 作为 编辑参数。

因此,在 setEditing 中,您可以检查:

if(editing) { .... }

查看我们是否正在进入或离开编辑状态。

Not sure I completely understood the question :/

When you press the "Done" button, I believe setEditing get's called again, but with NO as the editing parameter.

So in setEditing you could check for:

if(editing) { .... }

To see if we are entering or leaving the editing state.

愿与i 2024-08-25 17:53:25

您只需在 setEditing 中输入 if 条件即可。编辑按钮上的任何操作都会调用相同的方法。
您可以使用类似的代码

if(self.navigationItem.leftBarButtonItem)
{
 self.navigationItem.leftBarButtonItem = nil;
 self.navigationItem.hidesBackButton = NO;
}

您还可以在 if 中检查这两个条件。

You just have to pu if condition in setEditing. Same method gets called on any action on edit button.
You can have code like

if(self.navigationItem.leftBarButtonItem)
{
 self.navigationItem.leftBarButtonItem = nil;
 self.navigationItem.hidesBackButton = NO;
}

You can also check for both conditions in if.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文