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
[Bug] Modal transitions stopped working after first hero transition #644
Comments
Agree |
I'm experiencing the same issue, is there a known workaround for it? |
I have the same issue. And the statusbar will disappear when app enter background then back. |
This is preventing all projects that rely on modals to use Hero, is there a solution? |
I also ran into this issue. Is there a plan for fixing this? This is a major roadblock for my project. |
Same here, did someone found a solution for this? |
Any solution? |
Still have this issue on iOS 14! |
Any hint as to why this happen so I could analyze the source code? I'm perfectly OK in not using hero on the flows I need native pageSheet/formSheet presentations, but if you use Hero anywhere else it will break all future native modals. |
Interesting. I discovered today that a nasty work around for this is presenting a dummy VC and dismissing it in |
yes,
This situation happens at least hero is used when dismissing. I mean, showing modal with normal way, and dismissing modal with Hero by setting |
What I mean is, after having broken .pageSheet presentations when using hero transitions, one can fix the hierarchy by presenting and dismissing a dummy VC in fullscreen before trying to present your real VC in .pageSheet style.
|
I think I found a solution for this issue.
I changed those computed properties to stored properties by getting those values from // HeroTransition+UIViewControllerTransitioningDelegate.swift
public func animateTransition(using context: UIViewControllerContextTransitioning) {
transitionContext = context
fromViewController = fromViewController ?? context.viewController(forKey: .from)
toViewController = toViewController ?? context.viewController(forKey: .to)
fromView = fromView ?? context.view(forKey: .from)
toView = toView ?? context.view(forKey: .to)
transitionContainer = context.containerView
start()
} and removed workaround mentioned in @nobre84 's post: https://github.com/HeroTransitions/Hero/blob/develop/Sources/Transition/HeroTransition+Complete.swift#L89...L93
|
I did as well but got the issue from that thread which is black screen after transition as the presenting view is not restored to window of the transition messes with it which it seems Hero does. Did it work well in your test? I might have missed something 🤔
Em 20 de nov. de 2020, à(s) 04:37, Akira Fukunaga <notifications@github.com> escreveu:
I think I found a solution for this issue.
HeroTransition.fromView and .toView is computed property which comes from HeroTransition.fromViewController?.view and .toViewController?.view : https://github.com/HeroTransitions/Hero/blob/develop/Sources/Transition/HeroTransition.swift#L176...L177
I changed those computed properties to stored properties by getting those values from context.view(forKey: .from) and context.view(forKey: .to) , like this:
// HeroTransition+UIViewControllerTransitioningDelegate.swift
public func animateTransition(using context: UIViewControllerContextTransitioning) {
transitionContext = context
fromViewController = fromViewController ?? context.viewController(forKey: .from)
toViewController = toViewController ?? context.viewController(forKey: .to)
fromView = fromView ?? context.view(forKey: .from)
toView = toView ?? context.view(forKey: .to)
transitionContainer = context.containerView
start()
}
and removed workaround mentioned in @nobre84 's post<#644 (comment)>: https://github.com/HeroTransitions/Hero/blob/develop/Sources/Transition/HeroTransition+Complete.swift#L89...L93
ref: https://stackoverflow.com/questions/24338700/from-view-controller-disappears-using-uiviewcontrollercontexttransitioning/25901154#25901154
[https://avatars2.githubusercontent.com/u/40681391?s=400&v=4]<https://avatars2.githubusercontent.com/u/40681391?s=400&v=4>
[https://camo.githubusercontent.com/b6a12909f1e31185a69a73d59208c507a992236d3230f9fc18e85058ae3d19e7/68747470733a2f2f6769746875622e6769746875626173736574732e636f6d2f66617669636f6e732f66617669636f6e2e737667]<https://camo.githubusercontent.com/b6a12909f1e31185a69a73d59208c507a992236d3230f9fc18e85058ae3d19e7/68747470733a2f2f6769746875622e6769746875626173736574732e636f6d2f66617669636f6e732f66617669636f6e2e737667> GitHub
HeroTransitions/Hero<https://github.com/HeroTransitions/Hero>
Elegant transition library for iOS & tvOS. Contribute to HeroTransitions/Hero development by creating an account on GitHub.
[https://avatars2.githubusercontent.com/u/40681391?s=400&v=4]<https://avatars2.githubusercontent.com/u/40681391?s=400&v=4>
[https://camo.githubusercontent.com/b6a12909f1e31185a69a73d59208c507a992236d3230f9fc18e85058ae3d19e7/68747470733a2f2f6769746875622e6769746875626173736574732e636f6d2f66617669636f6e732f66617669636f6e2e737667]<https://camo.githubusercontent.com/b6a12909f1e31185a69a73d59208c507a992236d3230f9fc18e85058ae3d19e7/68747470733a2f2f6769746875622e6769746875626173736574732e636f6d2f66617669636f6e732f66617669636f6e2e737667> GitHub
HeroTransitions/Hero<https://github.com/HeroTransitions/Hero>
Elegant transition library for iOS & tvOS. Contribute to HeroTransitions/Hero development by creating an account on GitHub.
[https://camo.githubusercontent.com/53e7f06238afdd6866aa6f07439d1736d67b758a664629734558f90266b1435e/68747470733a2f2f63646e2e737374617469632e6e65742f53697465732f737461636b6f766572666c6f772f496d672f6170706c652d746f7563682d69636f6e40322e706e673f763d373364373961383962646564]<https://camo.githubusercontent.com/53e7f06238afdd6866aa6f07439d1736d67b758a664629734558f90266b1435e/68747470733a2f2f63646e2e737374617469632e6e65742f53697465732f737461636b6f766572666c6f772f496d672f6170706c652d746f7563682d69636f6e40322e706e673f763d373364373961383962646564>
Stack Overflow
"From View Controller" disappears using UIViewControllerContextTransitioning<https://stackoverflow.com/questions/24338700/from-view-controller-disappears-using-uiviewcontrollercontexttransitioning>
I got one problem and i have described it below.
I am using UIViewControllerContextTransitioning for custom transitions.
I have 2 view controllers, first view controller and second view controlle...
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#644 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AADQGD54SB72ZXF2BLUXP63SQYME3ANCNFSM4JNI5NHQ>.
|
Making myself clearer, when I start using fromView/toView from the transitionContext, there's a lot of code that actually trusts the fromView to be set and then Hero does nothing when doing a .overFullscreen transition. I'm playing with the code to try and make it more flexible to not having a fromView, but hasn't succeeded yet |
Okay I think I've got a solid work around:
|
The final solution would be to refactor Hero to work without assuming |
yes, unfortunately, |
UIApplication.shared.keyWindow?.addSubview(isPresenting ? fromView : toView) I found why this workaround causes this bug. This is because adding Ideal:
but, actual:
so, we have to add let transitionView = UIApplication.shared.keyWindow?.subviews.first
let dropShadowView = transitionView?.subviews.first
dropShadowView?.addSubview(isPresenting ? fromView : toView) (Please be careful, the above code doesn't work when modal on modal.)
|
Does this still happen in 1.6.0? |
In my case this bug still exists in 1.6.1 |
I know it's an odd request from a manager, but I'm not super up to speed with a lot of heros workings. If you have a patch could you please submit a pull request for review and I'll get to get this resolved as soon as possible. Thanks. |
I have found a different workaround but it may be specific for my presentation architecture. I need to use Hero transitions in a specific controller to present some items as expanded in a separate view controller. The items are displayed in a collection view and taping one of them opens the other view controller using Hero animation which simulates expanding of that item. Sometimes after I present the list controller I need to present some modal view on top of it with some success message or other information about some business flow. This caused the issue described in this thread where after second time I perform this flow the transitions stopped working and default push was used. I have found that if I disable hero in |
What did you do?
I use the following to display a VC with a modal transition:
self.present(vc, animated: true) {}
What did you expect to happen?
I expect the normal behavior of IOS 13:
However, this only works before using a Hero transition at another place in the app the first time!
What happened instead?
As soon as I have used Hero Transition the first time elsewhere in the app, the same modal transition behaves like this:
From this point, all modal transitions in the app behave like this.
Any ideas?
Thanks in advance!
Hero Version:
1.5.0
iOS Version(s):
13.2
Swift Version:
5.0
Devices/Simulators:
Both
The text was updated successfully, but these errors were encountered: