Comments (5)
I had the same problem.
My solution for now was to modify presentView so I can send along the current viewController among the parameters. Then, in the same method, instead of
self.rootViewController = window.rootViewController;
I set
self.rootViewController = viewController;
Where viewController is the current viewController.
Seems to work just fine...
Another catch though; if your "current" viewController is not the rootController (as it seems to be the case), chances are dismissing the popup will set your current viewController as the rootController. You may need to adapt to this situation also, maybe change a bit the way the popup is presented and dismissed.
But I guess this is not an issue in current recommended application flow.
from asdepthmodal.
My solution is way simpler:
if (window.rootViewController.presentedViewController)
self.rootViewController = window.rootViewController.presentedViewController;
else
self.rootViewController = window.rootViewController;
What do you think?
from asdepthmodal.
Ok my solution doesnt work very well...
the rootVC is deallocated . There is a need to keep it in memory still to go back
My issue is when i show a popup from a modal VC.
from asdepthmodal.
It certainly might be a good idea to get the presented view controller like that instead of passing it along like a parameter. If it works, then go for it.
But yes, there is a problem when you try to dismiss the popup. I finally skipped messing with the rootVC altogether. So I set self.rootViewController as the current presented view controller, commented the line: //window.rootViewController = self
The problem with this is that you lose the reference to the popup view when you try dismiss it, as it is not the rootViewController anymore. But the popup view should be the one on top of the stack. So I changed the dismiss methods to this:
-
(void)dismiss
{
UIWindow *window;window = [UIApplication sharedApplication].keyWindow;
UIViewController *topController = window.rootViewController;while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
if([topController isKindOfClass:[ASDepthModalViewController class]])
{
ASDepthModalViewController *controller;controller = (ASDepthModalViewController *)topController; [controller dismiss];
}
} -
(void)dismiss
{
[UIView animateWithDuration:kModalViewAnimationDuration
animations:^{
self.coverView.alpha = 0;
self.rootViewController.view.transform = CGAffineTransformIdentity;
self.popupView.transform = self.initialPopupTransform;
self.blurView.alpha = 0;
}
completion:^(BOOL finished) {
[self.rootViewController.view.layer setMasksToBounds:NO];
[self.blurView removeFromSuperview];
//[self restoreRootViewController]; <- no need to restore it anymore
self.rootViewController.view.layer.cornerRadius = 0;if (self.completionHandler) { self.completionHandler(); } [self dismissViewControllerAnimated:NO completion:nil]; }];
}
It's convoluted but it works for me, as I'm stuck with a project with no storyboards nor any of the new fancy ways to navigate through views...
from asdepthmodal.
The issue is that ASDepthmodal should be presented from our vc and not added as the root VC.
Then when dismissed it would return to the previous VC without any problem.
This would involve a little of architecture change to the whole class.
from asdepthmodal.
Related Issues (16)
- Dead Store in UIImage+Blur
- Please add semantic version tags. HOT 2
- Include on the Readme
- new Animations HOT 1
- Issue changing the rootViewController
- Issue when present a viewController over a presented viewController.
- How can I add an UIButton with IBAction on the added popover View HOT 1
- tar bar not hidden after popup view dismissed [iOS 7] HOT 2
- rootViewController UIImages lost alpha HOT 1
- 3MB leak in ASDepthModal / ASDepthModal / UIImage+Blur.m HOT 1
- Conflict with UIAlertView
- Dismiss needs a completion block HOT 1
- It's not working on iOS5 :( HOT 1
- suggestion fot tap outside to close HOT 5
- add completion block support for dismiss HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asdepthmodal.