Git Product home page Git Product logo

Comments (5)

Mewnatica avatar Mewnatica commented on August 30, 2024

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.

jonasman avatar jonasman commented on August 30, 2024

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.

jonasman avatar jonasman commented on August 30, 2024

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.

Mewnatica avatar Mewnatica commented on August 30, 2024

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.

jonasman avatar jonasman commented on August 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.