Forum Xamarin.iOS

How to discover presented ViewController

MarthughieMarthughie GBMember ✭✭

I need to react to a notification in a way which relies on which ViewController is being presented at the time, the notification handler obviously being an override in the AppDelegate class, so does not know too much about the structure of the View Controllers in the App.

What I have is a UITabBarController with four tabs (four UIViewControllers).

The first tab's UIViewController can navigate to a second UIViewController, and that can in turn modally Present a third ViewController

What I really need to know is whether or not the second UIViewController is displayed at the time the notification fires, so I can refresh the data.

I can obviously detect which is the SelectedIndex of the UITabBarController, but if it is the first one, I don't know which of the three UIViewControllers in that chain is being presented.

Using the IsPresented property always seems to return false, so I don't think that will do it.

Can anyone offer any suggestions ?

Sign In or Register to comment.