Password Screen Application in iPhone

This is the Simple PasswordScreen application. In this application we will see how to PassWordScreen display after pressing button. So lets see how it will worked.

Step 1: Open the Xcode, Create a new project using View Base application. Give the application “PasswordScreen”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the ViewController class for you. Expand Resources and notice the template generated a separate nib, PasswordScreenViewController.xib for the PasswordScreen application.

Step 4: Open the PasswordScreenViewController.h file and make the following changes:

#import <UIKit/UIKit.h>
@interface PasswordScreenViewController : UIViewController {
IBOutlet UITextField *userName;
IBOutlet UITextField *password;
}
(IBAction)PasswodAlert:(id)sender;
@end

Step 5: Double click the PasswordScreenViewController.xib file and open it to the interface builder. First drag the two label from the library and place it to the view window, select the label and bring up attribute inspector change the labels name into “Name” and “Details”. Drag two textfield and one round rect button from the library and place it to the view window. Now connect File’s Owner icon to the first TextField and select “userName” , do it once more for second TextField and select “password”. Select the round rect button and bring up Connection Inspector, connect Touch up Inside to the File’s Owner icon and select “PasswordAlert”. Save the .sib file, close it , and go back to the Xcode.

Step 6: Open the PasswordScreenViewController.m file and make the following changes in the file:

#import "PasswordScreenViewController.h"
@implementation PasswordScreenViewController
(IBAction)PasswordAlert:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Enter Your Password" message:@""
delegate:self cancelButtonTitle:nil
otherButtonTitles:@"Submit",nil];
[alert addTextFieldWithValue:@"" label:@"Enter Password"];
UITextField *textfield = [alert textFieldAtIndex:0];
textfield.secureTextEntry = YES;
[alert show];
}
(void)dealloc
{
[super dealloc];
}
(void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren’t in use.
}
(void)viewDidUnload
{
[super viewDidUnload];
}
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end

Step 7: Now compile and run the application on the simulator.

You can Download SourceCode from here PasswordScreen

Leave a Reply

Your email address will not be published. Required fields are marked *