Skip to content

Instantly share code, notes, and snippets.

@chuganzy
Last active January 17, 2019 19:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuganzy/6cd5b915b759e60de389 to your computer and use it in GitHub Desktop.
Save chuganzy/6cd5b915b759e60de389 to your computer and use it in GitHub Desktop.
モーダルで開いたUIViewControllerを一気に閉じる http://blog.ganzy.jp/objective-c/133
/* とにかくモーダルを全部閉じる */
// どこからでもOK
[[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:YES completion:nil];
// もしくはこちら
[[UIApplication sharedApplication].delegate.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
/* ある階層までのモーダルを閉じる */
// 閉じる元からの場合
[self.presentingViewController.presentingViewController.../*到達するまで*/ dismissViewControllerAnimated:YES completion:nil];
// 閉じた先からの場合
[self dismissViewControllerAnimated:YES completion:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment