iOS(obj-c)の画面遷移

Page content

・コードでの遷移 ・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];
[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];