LoginSignup
3
1

More than 5 years have passed since last update.

【Objective-C】UIViewControllerを任意に更新したい

Last updated at Posted at 2016-07-01

UIViewControllerの更新に見事にハマったので備忘録として残しておく

前提

クラスがUIViewControllerであること

手順

UINavigationControllerがラップしているViewControllersを

  • 取得する
  • 差し替える
  • 再セットする

サンプルコード

sample.m
    NSMutableArray *controllers = [self.navigationController viewControllers].mutableCopy;

    [controllers replaceObjectAtIndex:1 withObject:ViewController];

    [self.navigationController setViewControllers:controllers];

備考

※ご指摘ありがとうございます。
処理に無駄があった為、修正しました。

3
1
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
3
1