LoginSignup
92
84

More than 5 years have passed since last update.

モーダルで開いたUIViewControllerを全て閉じる話

Last updated at Posted at 2015-03-12

モーダルでViewControllerいっぱい開いちゃうときありますよね。それを一気に閉じる方法の紹介です。最強です。全部一気に閉じちゃいます。

とにかくすべて閉じる方法

Objective-C 
[[UIApplication sharedApplication].keyWindow.rootViewController 
dismissViewControllerAnimated:YES completion:nil];

または,

Objective-C
[[UIApplication sharedApplication].delegate.window.rootViewController 
dismissViewControllerAnimated:YES completion:nil];

あるところまで閉じる方法

Objective-C
[self.presentingViewController.presentingViewController.../*到達するまでひたすら書く*/ 
dismissViewControllerAnimated:YES completion:nil];

一つだけ閉じる方法

Objective-C
[self dismissViewControllerAnimated:YES completion:nil];

使えます!!

92
84
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
92
84