【问题标题】:Is there an inverse of `setEditing` for when editing is complete?编辑完成时是否存在与“setEditing”相反的情况?
【发布时间】:2010-01-19 13:14:25
【问题描述】:

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

当按下“编辑”按钮时,我正在处理。 LHS 后退图标变暗,我的新图标进来了,然后一旦我再次点击“编辑”按钮,后退按钮就会回来。

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

这是我目前所拥有的:

 (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)editing animated:(BOOL)animated {的倒数,我可以在哪里做:

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

是否有 (void)setEditing:(BOOL)editing 的倒数?

【问题讨论】:

    标签: iphone button uinavigationcontroller navigation


    【解决方案1】:

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

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

    所以在 setEditing 中你可以检查:

    if(editing) { .... }
    

    查看我们是进入还是离开编辑状态。

    【讨论】:

      【解决方案2】:

      你只需要在 setEditing 中 pu if 条件。在编辑按钮上的任何操作上都会调用相同的方法。 你可以有类似的代码

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

      你也可以在 if 中同时检查这两个条件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-28
        • 1970-01-01
        • 2021-06-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多