1.模态视图的静态工厂方法调用:
+ (void)dismiss
{
UIWindow *window;
window = [UIApplication
sharedApplication].keyWindow;
if([window.rootViewController
isKindOfClass:[ASDepthModalViewController
class]])
{
ASDepthModalViewController *controller;
controller = (ASDepthModalViewController *)window.rootViewController;
[controller
dismiss];
}
}
2.调用实力变量的模态视图转化函数
- (void)dismiss
{
[UIView
animateWithDuration:kModalViewAnimationDuration
animations:^{
self.coverView.alpha =
0;
self.rootViewController.view.transform
= CGAffineTransformIdentity;
self.popupView.transform =
self.initialPopupTransform;
}
completion:^(BOOL finished) {
[self
restoreRootViewController];
}];
}
3.重新修改根视图控制器:
- (void)restoreRootViewController
{
UIWindow *window;
window = [UIApplication
sharedApplication].keyWindow;
[self.rootViewController.view
removeFromSuperview];
self.rootViewController.view.transform
= window.rootViewController.view.transform;
window.rootViewController =
self.rootViewController;
}