I am developing an application in which I am using two navigation Controllers , and uilocalNotification
first NavigationViewController N1 has two ViewControllers v1 and v2 second NavigationViewController N2 has two ViewControllers v3 and v4
Also , when application is in background , and if UILocalNotification appears and if I click on it , the application should detect which navigation Controller and which viewController is displayed and then switch to another navigationController's viewcontroller .
Ex:- If v2 in N1 is displayed , then after notification is clicked , then switched to v3 in N2 is displayed
How to do this ??
just paste this bellow methods in your AppDelegate.m
file and call particular method when you want to change UINavigationController
...
For Example: if you are in v2
of N1
and notification changed then call bellow method like bellow...
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate setRootViewControllerN2];
use this bellow methods for switch navigation controller with animations..
1. setRootViewControllerN1 : this is for set RootViewController with N1 navigationController.
-(void)setRootViewControllerN1{
self.window.rootViewController = N1;
[self.window makeKeyAndVisible];
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionFade];
[animation setDuration:0.5];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseInEaseOut]];
[[self.window layer] addAnimation:animation forKey:kAnimationKey];
}
2. setRootViewControllerN2 : this is for set RootViewController with N2 navigationController.
-(void)setRootViewControllerN2{
self.window.rootViewController = N2;
[self.window makeKeyAndVisible];
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionFade];
[animation setDuration:0.5];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseInEaseOut]];
[[self.window layer] addAnimation:animation forKey:kAnimationKey];
}