Pythonista-Issues
Pythonista-Issues copied to clipboard
ui.NavigationView - pop_to_root_view
Ability to pop_to_root_view(animated=True) would be nice.
I assume that would mean "pop all views except the root view"? That would be useful.
In general it would be nice if the navigation stack was accessible in some way, at least read-only. At the moment there is no way to tell how many and which views are pushed. IIRC there's also no way to tell when the user taps the "back" button, so it's not possible to implement this manually (at least not without objc_util stuff).
Yup, just to simply mimick UINavigationController popToRootViewControllerAnimated:. There're other useful methods like viewControllers, visibleViewController, topViewController, ... and these can be mimicked (if I use Ole's naming) via views, visible_view, top_view, ...
For anyone that needs to use this here’s an example of how I managed to do it using the objc_instance of the NavigationView:
nc = navigation_view.objc_instance.navigationController()
nc.popToRootViewControllerAnimated_(False)
Found it here: https://gist.github.com/jsbain/3033d2f71d6913b5b82e6de818c5764e