Comments (4)
Thank you for the comprehensive report. I'll look into this as soon as I can.
from swiftui-navigation-transitions.
So I think maybe better not to introduce the one-line fix into the library (and we also rarely have the navigation bar visibility varying between screens? 🫠)
I concur. If anyone else raises this issue, now we have somewhere to direct them for answers.
I guess I'll be closing this now. Thank you for your research 🤝
from swiftui-navigation-transitions.
Sorry for the delay. Very weird indeed, most definitely a SwiftUI bug that's hidden by the fact that one can't swipe back when nav bars are hidden in vanilla SwiftUI.
Your solution does (somehow? 🤯) work, so I'm going to apply it selectively on iOS 17 and write some regression UI tests in order to have our bases covered for when iOS 18 comes around. I'm currently quite busy so this will take me until sometime next week, but feel free to do it yourself and PR it if you feel like it. My current working branch is https://github.com/davdroman/swiftui-navigation-transitions/tree/fix/freezing-ios-17.
from swiftui-navigation-transitions.
Hi @davdroman Thanks for your time. I found that my one-line fixed the issue at first but then it introduced another problem.
navigationController.setNavigationBarHidden(false, animated: true)
The problem is in this context, we don't know if the target view controller needs a hidden navigation bar or not.
So if we go back and forth between screen A (not hidden) and screen B (hidden bar), or even more screens involved, the navigation bar visibility will be messed up. Even freezing happens when the visibility doesn't match what we declared in SwiftUI view.
In my project, I workaround this issue by not patching the library, but using a delegate instead
.navigationTransition(.default, interactivity: panNavigationState.isPanEnabled ? .pan : .disabled)
.introspectNavigationController { navigationController in
if #available(iOS 17, *) {
navigationController.delegate = NavigationControllerBaseDelegate.shared
}
}
class NavigationControllerBaseDelegate: NSObject, UINavigationControllerDelegate {
static let shared = NavigationControllerBaseDelegate()
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
navigationController.setNavigationBarHidden(viewController.isNavBarHidden, animated: true)
}
}
isNavBarHidden
is the property I injected into the underlying UIViewController
of the SwiftUI view, where I set the navigation bar visibility
.navigationBarHidden(true)
.introspectViewController { viewController in
viewController.isNavBarHidden = true
}
Quite a lot of weird code but the solution is working fine so far in my project. So I think maybe better not to introduce the one-line fix into the library (and we also rarely have the navigation bar visibility varying between screens? 🫠)
from swiftui-navigation-transitions.
Related Issues (18)
- Unable to disable swipe back if use this animation HOT 2
- iOS 17.1 - Navigation animation issues HOT 1
- Navigation bar disappears after rotating device in destination view and coming back HOT 2
- Bump to Swift 5.9 (by April 2024)
- Transition starts working only after second execution HOT 10
- Change fade transient view background color HOT 2
- Dynamic change of interactivity is not supported? HOT 1
- present animation HOT 1
- how to create a 'nothing' transition HOT 1
- slide-inverse
- `ZPosition` Transition
- DocC
- Will there be macOS support? HOT 1
- Change transition ?
- 3D Transitions
- Tests HOT 1
- Error When Archive (Command SwiftCompile failed with a nonzero exit code) HOT 7
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 swiftui-navigation-transitions.