如何在ios5中使用segue推送的视图控制器中更改后退按钮标题

时间:2013-09-23 12:42:35

标签: ios uinavigationbar

使用下面的代码我打开一个信息屏幕。 一切正常,屏幕打开,标题显示为我想要的,但我无法获得默认的后退按钮标题更改

我应该怎么做xcode5

感谢

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"infoRegularSegue"])
    {


        FirstViewController *destViewController = segue.destinationViewController;
        destViewController.title = NSLocalizedString(@"Information", title of information     view);

//this code below does not work      
  destViewController.navigationItem.backBarButtonItem.title = @"test";

//ive also tried leftbuttonitem

    }
}

1 个答案:

答案 0 :(得分:7)

经过大量搜索并在此论坛上尝试各种解决方案之后,我终于得到了一些有用的内容,我将在下面发布,以便其他人在此时陷入困境。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"infoRegularSegue"])
    {


        FirstViewController *destViewController = segue.destinationViewController;
        destViewController.title = NSLocalizedString(@"Information", title of information view);

        //here is the solution to my problem
        UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle:NSLocalizedString(@"Return", returnbuttontitle) style:     UIBarButtonItemStyleBordered target:nil action:nil];
        self.navigationItem.backBarButtonItem = backButton;

    }
}