gpt4 book ai didi

ios - NavigationController 更改后退按钮

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

我有两个问题:

问题 1:我正在尝试更改导航后退按钮,我正在从父 ViewController 执行此操作:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"imgrdy"]) {
VCImageEditingViewController *ieVC = (VCImageEditingViewController *)segue.destinationViewController;
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"New" style:UIBarButtonItemStyleBordered target:nil action:@selector(handleNewBtnNav:)];
[[self navigationItem] setBackBarButtonItem: newBackButton];
}
}
-(IBAction)handleNewBtnNav:(id)sender {
UIAlertView *alertNew = [[UIAlertView alloc]initWithTitle:@"New photo" message:@"Are you sure?" delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
[alertNew show];
}

标题确实已更改,但未显示警报。我尝试将目标更改为“self”和“ieVC”,但仍然没有。

问题 2:有没有办法只改变一个 ViewController 的后退按钮的标题?还是我必须对每个父 ViewController 进行相同的更改?

谢谢。

最佳答案

在声明按钮时使用 target:self,它是 Action 的接收者,你说它是 nil

UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"New" style:UIBarButtonItemStyleBordered target:self action:@selector(handleNewBtnNav:)];

关于ios - NavigationController 更改后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19465245/

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