[英]Navigate iOS Storyboard ViewControllers from AppDelegate
I'm new to iOS development. 我是iOS开发的新手。 I have a facebook login app which invokes delegate method in the appdelegate.
我有一个Facebook登录应用程序,它在appdelegate中调用委托方法。 I did this using .xib views but I need to do it on the storyboard.
我使用.xib视图执行此操作,但我需要在故事板上执行此操作。 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.
我有一个LoginViewController,它具有一个登录按钮,一旦用户单击它,便显示FB登录,并且用户登录后从那里调用appdelegate方法,我需要导航到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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.