Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransitionController - Initial RootViewController view lifecycle not occuring #940

Closed
markst opened this issue Oct 26, 2017 · 9 comments
Closed

Comments

@markst
Copy link
Contributor

markst commented Oct 26, 2017

The initial root view controller view lifecycle functions are not being called on initial load of root view controller. All subsequent lifecycle functions are working as expect.

@markst
Copy link
Contributor Author

markst commented Oct 26, 2017

This is due to shouldAutomaticallyForwardAppearanceMethods being implemented & not calling the appropriate appearance transition functions on initial setup of root view controller:

#938 (comment)

@markst markst changed the title TabsController - Initial RootViewController view lifecycle not occuring TransitionController - Initial RootViewController view lifecycle not occuring Oct 26, 2017
@markst
Copy link
Contributor Author

markst commented Oct 26, 2017

There needs to be a feature where by lifecycle functions are performed when updating root view controller directly.

self.rootViewController = UIViewController() // View lifecycle not called
self.transition(to: UIViewController(), completion: nil) // View lifecycle called

@daniel-jonathan
Copy link
Member

I see what you are describing. I have an idea of how to make it work correctly. I will give it a try after another task I am working on.

@markst
Copy link
Contributor Author

markst commented Oct 26, 2017

Not a huge fan of it, but passing the transition logic on as follows, resolved it for me:

open class TransitionController: UIViewController {

    open override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.rootViewController.beginAppearanceTransition(true, animated: animated)
    }
    
    open override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.rootViewController.endAppearanceTransition()
    }
    
    open override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        self.rootViewController.beginAppearanceTransition(false, animated: animated)
    }
    
    open override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        self.rootViewController.endAppearanceTransition()
    }

@daniel-jonathan
Copy link
Member

Well I was thinking that in the shouldAutomaticallyForwardAppearanceMethods call, we can return true on the first instance.

@markst
Copy link
Contributor Author

markst commented Oct 26, 2017

yeah sounds fine. trusting it's toggled at the right occasion

markst added a commit to markst/Material that referenced this issue Oct 26, 2017
@daniel-jonathan
Copy link
Member

daniel-jonathan commented Oct 26, 2017

I actually like your solution better as it is clear as to what is happening. With a hidden flag, which I am not a fan of, does not demonstrate clarity when looking through the code. I am going to test how your solution works.

@daniel-jonathan
Copy link
Member

This is the corresponding commit that will be in the next release 5e8497d, thank you!

@daniel-jonathan
Copy link
Member

Please find this fix in Material 2.12.8 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants