ViewController直接返回最底层

2015-08-11  本文已影响69人  陈世美_

首先,必须知道现在整个APP最顶层的ViewController是哪个,我的做法是在每个ViewController的viewWillAppear中记录一下,当然这个操作是自动完成的,因为每个项目,我都会从UIViewController派生一个子类,然后再从这个子类派生所有的ViewController方便管理.

@interface MMViewController : UIViewController

@end

@implementation MMViewController

- (void)viewWillAppear:(BOOL)animated

{

APP.presentingController = self;

}

@end

if( APP.presentingController)

{

UIViewController *vc = self.presentingController;

if( !vc.presentingViewController)

{

        return;

}

while(vc.presentingViewController)

{

        vc = vc.presentingViewController;

}

[vc dismissViewControllerAnimated:YES completion:^{

}];

}

上一篇 下一篇

猜你喜欢

热点阅读