'Move to new view controller after successful login
I am experimenting with developing my first app. I need some help on moving from one view controller to the next after a successful login. I've looked up countless methods but just don't seem to understand. this is what I have so far:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
credentialsDictionary = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"password", nil] forKeys:[NSArray arrayWithObjects:@"username", nil]];
}
- (IBAction)SubmitCredentials;
{
if ([[credentialsDictionary objectForKey:badgenumberField.text]isEqualToString:passwordField.text]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Valid Credentials" message:@"Access Granted." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Credentials" message:@"Access Denied." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
}
;}
@end
Can someone help me get to the next step please it would be greatly appreciated. Can you also let me know what segue i should be using to move to the next controller after the successful login.
Solution 1:[1]
After you verify the correct credentials, if you are not using storyboard you should initialize other view controller and them push to it.
something like this:
HomeViewController *ctrl = [[HomeViewController alloc] initWithNibName:[[BaseHomeViewController class] description] bundle:nil];
[self.navigationController pushViewController:ctrl animated:YES];
change HomeViewController
to the view controller that you wanna move
if you are not using a baseViewController
like this:
// HomeViewController.h
#import "BaseHomeViewController.h"
@interface HomeViewController : BaseHomeViewController
@end
Change the file BaseViewController
to your xib view controller class
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Lucas Batista Gabriel |