简体   繁体   中英

Navigate iOS Storyboard ViewControllers from AppDelegate

I'm new to iOS development. I have a facebook login app which invokes delegate method in the appdelegate. I did this using .xib views but I need to do it on the storyboard. I have the LoginViewController which has a login button and once user click on it shows FB login and after user logged in it invokes appdelegate method from there I need to navigate to MainViewController. I have tried few ways to do this but its not working. Below is the code that I have tried last. But it's not working or not even give error. Please help me :(((

SCAppDelegate* appDelegate = (SCAppDelegate *)[[UIApplication sharedApplication] delegate];
LoginViewController *mvc = (LoginViewController *)appDelegate.window.rootViewController;
MainViewController *lvc2 = [mvc.storyboard instantiateViewControllerWithIdentifier:@"MainViewController"];
[_navController presentModalViewController:lvc2 animated:YES];

try this one..

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil]; 
MainViewController *lvc = [storyboard   instantiateViewControllerWithIdentifier:@"StoryBoard ID of MainViewController"];
 [(UINavigationController *)self.window.rootViewController pushViewController:lvc animated:NO];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM