简体   繁体   English

UINavigationController:如何管理“取消”按钮和“后退”按钮

[英]UINavigationController: How to manage Cancel button and back button

Lets say I have two controller A & B... When I'll navigate from A to B then back button on B Controller will be A. 假设我有两个控制器A和B ...当我从A导航到B时,B上的后退按钮将为A。

So my problem is... On a button click I have to change backButton to Cancel Button.. and on another back button it should appear backButton A in back button arrow style. 所以我的问题是...在按钮上单击我必须将backButton更改为Cancel Button ..,在另一个后退按钮上,它应以后退按钮箭头样式显示backButtonA。

Please suggest. 请提出建议。

Do the following, 请执行下列操作,

To SHOW the Cancel button: 显示 “取消”按钮:

- (void)showCancelButton {

    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(someMethod)];
    [self navigationItem] setLeftBarButtonItem:cancelButton];
    [cancelButton release];
}

To HIDE the Cancel button: 隐藏 “取消”按钮:

- (void)hideCancelButton {

    [self navigationItem] setLeftBarButtonItem:nil];
}

Make sure self.navigationController.navigationItem.hidesBackButton is NO . 确保self.navigationController.navigationItem.hidesBackButtonNO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM