Pythonista-Issues icon indicating copy to clipboard operation
Pythonista-Issues copied to clipboard

ui.NavigationView - pop_to_root_view

Open zrzka opened this issue 8 years ago • 3 comments
trafficstars

Ability to pop_to_root_view(animated=True) would be nice.

zrzka avatar Sep 13 '17 05:09 zrzka

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).

dgelessus avatar Sep 13 '17 09:09 dgelessus

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, ...

zrzka avatar Sep 13 '17 10:09 zrzka

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

jfgomez86 avatar Jul 27 '20 03:07 jfgomez86