Replies: 3 comments
-
I'm having the same problem. Is that intended? |
Beta Was this translation helpful? Give feedback.
-
Hi @oskarek and @thomasdelgado, this is just a limitation of UIKit (and SwiftUI). You cannot simultaneously dismiss+navigate in UIKit, you must space them out a bit. There are even logs in the console letting you know that something is wrong:
We don't want to try to bake fixes for UIKit/SwiftUI problems in our libraries because it always bites us in the end. Since this isn't an issue with the library I am going to convert it to a discussion. Please feel free to continue the conversation over there! |
Beta Was this translation helpful? Give feedback.
-
@mbrandonw I would argue that since the promise of this framework is to create a binding between view controllers and models such that the Also note that at present not only is the view controller for the new |
Beta Was this translation helpful? Give feedback.
-
Description
We have noticed what we think is an issue with this library. The problem happens when using the
present(item:)
method to present a view controller from another, and switch to another one.Checklist
main
branch of this package.Expected behavior
I expect the new view controller to replace the previously presented one, when the binding driving the navigation is updated to point to the other one.
Actual behavior
Some of the times (it seems to be even most of the times), what instead happens is that the presenting view controller is closed right after the presented one, instead of switching to presenting the new one, along with a console warning about trying to present a view cotroller on top of one whose view is not in the view hierarchy.
Steps to reproduce
present(item:)
.This repo reproduces the bug and demos the scenario in which it happens. There is also a
fix
-branch that uses a fork of this library with a potential fix.Just open the app in the project, and tap "Present A", then "Present B", then "Present C".
So it seems to be some race condition happening within the navigation machinery. As you can see by looking at the fix in the fork linked above, it seems to be resolved by delaying the dismissal of view controllers with "one tick" by wrapping it in a
DispatchQueue.main.async {...}
, but I'm not sure it's a good solution.SwiftUI Navigation version information
2.2.2
Destination operating system
iOS 18
Xcode version information
16.1.0
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions