I am new to IOS. I created a simple storyboard layout, something as shown below:
-> Navigation --> login --> Welcome screen
When I build and run the setup, I can see the login page with username and password textfields and a button ('login').
But I am unable to understand How I should redirect the page to welcome screen when the user has entered something inside the username and password textfields.
To achieve this, I added a controller LoginViewController
to the login page and inside that controller's .h
file, I added the following code:
#import "LoginViewController.h"
@interface LoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *username_text;
@property (weak, nonatomic) IBOutlet UITextField *pwd_text;
@end
@implementation LoginViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)login_btn:(id)sender {
if([self validOrNot]){
// UIviewcontrollerWelcom *vc = [[DashboardViewController alloc] init];
// [self presentViewController:vc animated:YES completion:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:WelcomeViewController];
[self presentViewController:navigationController animated:YES completion: nil];
}
}
- (BOOL)validOrNot{
if ([self.pwd_text hasText] && [self.username_text hasText]) {
return YES;
}
else
{
return NO;
}
}
Please guide me how should I redirect to next page which is welcome screen when user enter something in username and password textfields of the login page.