Reputation: 4058
In the Android section of Xamarin Projekt there is "((AndroidAppFeatures)App.AppFeatures).Activity" to get the current Page.
Is there something similar for Ios to get the current viewController?
Thanks ;)
Upvotes: 0
Views: 935
Reputation: 406
Quotes from Adam Kemp on https://forums.xamarin.com/discussion/24689/how-to-acces-the-current-view-uiviewcontroller-from-an-external-service
There is no single "current" view controller in iOS. There could be multiple view controllers on the screen at once (either nested or presented as popovers or modals). I think the closest equivalent to what you're asking for would be to start with the key window's root view controller and then find the "most-presented" (for lack of a better term) view controller
And his code example:
var window= UIApplication.SharedApplication.KeyWindow;
var vc = window.RootViewController;
while (vc.PresentedViewController != null)
{
vc = vc.PresentedViewController;
}
This should help you get there
Upvotes: 1