Help us understand the problem. What is going on with this article?

[Objective-C] ViewController間の遷移

More than 3 years have passed since last update.

遷移の仕方一覧

よく頭が混んがらがるのでメモまとめました
いまだ何がベストかちょっとわかってないですが・・・;

以下を考慮して臨機応変に
・コードでの遷移
・StoryBoardのsegueを使った遷移
・NavigationControllerを使った遷移

Present

[self presentViewController:移動先ViewController animated:YES completion:nil];

segue

[self performSegueWithIdentifier:@"セグエのID" sender:self];

Push

[self.navigationController pushViewController:移動先ViewController animated:YES];

Pop

指定ビューコントローラーへ

[self.navigationController popToViewController:viewController animated:YES];

前の画面に戻る

[self.navigationController popViewControllerAnimated:YES];

NavigationControllerの1番目の画面に戻る

[self.navigationController popToRootViewControllerAnimated:YES];

StoryBoard

・StoryBoard ID

※storyboardファイルで 'identify → StoryBoard ID'の入力が必要

UIStoryBoard* storyBoard = [UIStoryboard storyboardWithName:@"ストーリボードID" bundle:nil];
UIViewController* viewController = [storyboard instantiateInitialViewController];

・StoryBoard initial ViewController

※storyboardファイルで 'is initial View Controller'のチェックが必要

UINavigationController* rootNavigationController = [storyboard instantiateInitialViewController];
UIViewController* viewController = [[rootNavigationController viewControllers] lastObject];

そのうち
Swiftのメモもまとめたいです

piyomarudayo
基本はSwiftエンジニアです 最近はRuby、wordpressをちょこちょこバイトしてます 基本的にはメモ書き利用です。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away