I am working in a static library project and I want to push a view controller in navigation controller of iOS project How can I do it ? I am doing it as follows:
UIStoryboard * storyboard = [[[UIApplication sharedApplication] keyWindow] rootViewController].storyboard;
UIViewController* pushtoVC = [storyboard instantiateViewControllerWithIdentifier:@"home"];
UINavigationController *navController = [[[[UIApplication sharedApplication] keyWindow]rootViewController] navigationController];
[navController pushViewController:pushtoVC animated:YES];
I have also tried the following code but its is not pushing view controller.
UIStoryboard * storyboard = [[[UIApplication sharedApplication] keyWindow] rootViewController].storyboard;
UIViewController* pushtoVC = [storyboard instantiateViewControllerWithIdentifier:@"home"];
UINavigationController *navController = [[[[UIApplication sharedApplication] keyWindow]rootViewController] navigationController];
[navController pushViewController:pushtoVC animated:YES];
But if I am using present view controller modally it is working but navigation controller hides only View controller was loaded. the code which is working to present modally without navigation controller is as follows.
UIStoryboard * storyboard = [[[UIApplication sharedApplication] keyWindow] rootViewController].storyboard;
if ([[storyboard valueForKey:@"identifierToNibNameMap"] objectForKey:@"home"]) {
// the view controller exists, instantiate it here
UIViewController* myVC = [storyboard instantiateViewControllerWithIdentifier:@"home"];
myVC.modalPresentationStyle = UIModalPresentationFullScreen;
[[[[UIApplication sharedApplication]keyWindow] rootViewController] presentViewController:myVC animated:YES completion:nil];
the above code is presenting view controller modally but navigation controller removed from view controller but I want to navigate to home view controller with navigation controller.