0

我有两个问题:

问题 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 进行相同的更改?

谢谢你。

4

1 回答 1

1

声明按钮时使用 target:self ,即动作的接收者,你说的是 nil

UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"New" style:UIBarButtonItemStyleBordered target:self action:@selector(handleNewBtnNav:)];
于 2013-10-19T10:58:52.873 回答