I recently started a new project and after I successfully set up a login page, I came into a problem.
If I type in valid credentials in the text fields, my app should do the following:
if (user) {
[self.delegate loginViewControllerDidLogin:self];
...
The "if user" part means that everything was okay. After a few hours of searching I got to know that my [self.delegate loginViewControllerDidLogin:self];
should be defined in the AppDelegate.m
file. Here I wrote the following code:
- (void)loginViewControllerDidLogin:(LoginViewController *)controller {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController * ViewController = [[UIViewController alloc] init];
[self.window addSubview:ViewController.view];
[self.window.rootViewController presentViewController:ViewController animated:YES completion:nil];
}
My problem is that I cannot define the ViewController on my story board, so I cannot connect the code with the ViewController itself.
So basically I would like the app to open a new ViewController after logging in.
On your storyboard select the view controller you want to display and fill out the "Storyboard ID":
Then instantiate it like this:
UIViewController * ViewController = [storyboard instantiateViewControllerWithIdentifier:@"YourVCStoryboardID"];
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.