从第三个视图控制器弹出到第一个视图控制器(根视图控制器)

发布于 2024-08-29 22:21:14 字数 778 浏览 2 评论 0原文

我正在使用一个导航栏,根据用户选择的内容推送多个视图。现在我需要从第三个控制器弹出到第一个视图控制器。应用程序弹出到第一个视图控制器,但导航项没有像第二个一样更改视图控制器但是,我需要更改 navigationItems。

我使用的代码:appdelagte.h

Bool isDelete;
@property(nonatomic)Bool isDelete;

appDelegate.mthirdViewController

@synthesize isDelete;

-(void)viewWillAppear:(Bool)animated {
  appDelegate.isDelete=YES;
  [self.navigationController popViewControllerAnimated:YES];
}

secondViewController.m

-(void)viewWillAppear:(Bool)animated {
    if(appDelegate.isDelete==YES)
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

这里弹出到第一个视图控制器,但navigationItems没有像在第二个视图控制器中那样被更改

任何人都可以帮助我解决这个问题。提前致谢。

I am using a navigation bar on which I push several views according to what the user selects.Now I need to pop to first view controller from third controller.The applications pop to first view controller but navigationItems are not been changed as it is in second view controller but, I need to change navigationItems.

Code that I used: appdelagte.h

Bool isDelete;
@property(nonatomic)Bool isDelete;

appDelegate.m

@synthesize isDelete;

thirdViewController:

-(void)viewWillAppear:(Bool)animated {
  appDelegate.isDelete=YES;
  [self.navigationController popViewControllerAnimated:YES];
}

secondViewController.m

-(void)viewWillAppear:(Bool)animated {
    if(appDelegate.isDelete==YES)
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

Here pop to first view controller but navigationItems are not being changed as it is in secon view controller

Any one help me to solve this.Thanks in advance.

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

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

发布评论

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

评论(1

醉酒的小男人 2024-09-05 22:21:14

也许你可以在不显示第三个 ctrl 的情况下执行此行为?就像在第二个 ctrl 中检查 if(appDelegate.isDelete==YES) 一样。

- (void) showThird {
    if(appDelegate.isDelete == NO) {
        MyThirdCtrlClss *ctrl = [[MyThirdCtrlClss alloc] init];
        [self.navigationController pushViewController:ctrl animated:YES];
        [crel release];
    } else {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
}

May be you can do this behavior without showing third ctrl? Like do this check if(appDelegate.isDelete==YES) in second ctrl.

- (void) showThird {
    if(appDelegate.isDelete == NO) {
        MyThirdCtrlClss *ctrl = [[MyThirdCtrlClss alloc] init];
        [self.navigationController pushViewController:ctrl animated:YES];
        [crel release];
    } else {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文