Mil0R3
Mil0R3

Reputation: 3956

push a UIViewController when received a remote notification

The project's initial viewController is a UITabBarViewController, I want to push a new viewController when received a remote notification, but not sure now which viewController is in, how to deal with it?

Upvotes: 1

Views: 56

Answers (1)

iphonic
iphonic

Reputation: 12717

You can easily determine which UIViewController is visible currently, see below, considering code is written in AppDelegate to access UIWindow property directly

UITabBarController *tabController=(UITabBarController *)self.window.rootViewController;

UINavigationController *selectedNav=(UINavigationController *)tabController.selectedViewController;

UIViewController *viewControllerVisible=[[selectedNav viewControllers] lastObject];

Then upto you what you want to do.

Hope this helps.

Cheers.

Upvotes: 2

Related Questions