views:

32

answers:

1

I am doing a normal viewBased application and have added another viewController(along with the xib). When the application starts, normally it will display its own view. I am doing an action and is going to another viewController class. From this class, I want to check which viewController is being displayed currently in the view.

How can I do this? Does anyone have an idea?

A: 

If you are using a TabBarController:

UITabBarController *tabBarController; // Intialized somewhere

 currentNavController = ((UINavigationController *)tabBarController.selectedViewController);

 if ([currentNavController.topViewController class] == [ClassImCheckingFor class])
 -OR-
 if ([currentNavController.visibleViewController class] == [ClassImCheckingFor class])

Otherwise you can interate through your viewcontrollers and do whatever checks are necessary to determine who is on top. He he.

Kenny