I'm pretty new to Objective-C so hopefully this all makes sense. Here after authentication of user name and password fields the UIAlertView
pops up. What I want is when the user presses the UIAlertViewButton
. The Control should navigate to instruction view controller.
But here it is not working
Here is .h file code:
#import <UIKit/UIKit.h>
#import "InstructionBIDViewController.h"
@interface SignInViewController : UIViewController<UIAlertViewDelegate>{
IBOutlet UITextField *usernamefield;
IBOutlet UITextField *password;
NSDictionary *creditialDictionary;
}
@property (strong, nonatomic) InstructionBIDViewController *viewControllerinst;
-(IBAction)enterCredential;
//-(void) submitData;
@end
Here is .m file code:
#import "SignInViewController.h"
#import "InstructionBIDViewController.h"
@interface SignInViewController ()
@end
@implementation SignInViewController
@synthesize viewControllerinst;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//[self submitData];
creditialDictionary =
[[NSDictionary alloc ] initWithObjects:
[NSArray arrayWithObjects:@"password",@"1234",nil]
forKeys:
[NSArray arrayWithObjects:@"username", @"alex",nil]];
}
-(IBAction)enterCredential
{
if ([[creditialDictionary objectForKey:usernamefield.text]
isEqualToString:password.text]) {
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle:@"Correct Password"
message:@"This password is correct"
delegate:self
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
} else {
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle:@"InCorrect Password"
message:@"This password is incorrect"
delegate:self
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
}
}
//-(void) alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex{
//Here the functionality that i want to perform ...but it is not working
- (void)alertView:(UIAlertView *)alertView
didDismissWithButtonIndex:(NSInteger)buttonIndex{
// u need to change 0 to other value(,1,2,3) if u have more buttons.
// then u can check which button was pressed.
if (buttonIndex == alertView.cancelButtonIndex) {
// Cancelled
viewControllerinst = [[InstructionBIDViewController alloc]
initWithNibName:@"InstructionBIDViewController" bundle:nil];
[self.navigationController pushViewController:viewControllerinst
animated:YES];
}
}
@end
Please help me to perform this navigation using UIAlertView
?