LoginSignup
11
11

More than 5 years have passed since last update.

UINavigationBarのBackボタンのタイトルを変える

Posted at

備忘録として。
UINavigationControllerにViewControllerをpushすると
自動的に前画面のタイトルがBackボタンのタイトルに設定されるが
これを変えたい場合は、画面遷移する前に設定しておく必要がある。

//次の画面に遷移するボタン
- (void)actionButtonNextViewController:(id)sender
{

    UIBarButtonItem *backBarButtonItem= [[UIBarButtonItem alloc] initWithTitle:@"戻る"
                                                                         style:UIBarButtonItemStylePlain 
                                                                        target:nil
                                                                        action:nil];

    //遷移する前にタイトルを設定しておく
    [self.navigationItem setBackBarButtonItem:backBarButtonItem];

    //画面遷移
    [self performSegueWithIdentifier:@"NextViewController" sender:self];
}
11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11