I have a view controller A in the Storyboard named "X" in it i have a button . On clicking it I am checking the success response for the API and after that I need to navigate to the view controller B in the storyboard "B" .
I am using the code:
let loginstoryboard = UIStoryboard(name: "Login", bundle: nil)
let loginController = loginstoryboard.instantiateViewController(withIdentifier: "login") as? LoginViewController
self.navigationController?.pushViewController(loginController!, animated: true)
So it is not working for me. What is the issue?
Please follow below steps.
Please check sample image of StoryboardID
Sample Code
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:"YourStoryBoardName" bundle:nil];
UIViewController *loginViewController = [storyBoard instantiateViewControllerWithIdentifier:"LoginViewController"];
// If Login View Controller is not a Navigation Controller then you need to create Navigation Controller
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:loginViewController];
[self.navigationController pushViewController:viewController animated:true];