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;



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
[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);



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

You can Download SourceCode from here PasswordScreen

Leave a Comment:

Tom Jay says September 23, 2011

Your app will not be approved if you use this method.

“3.3.1 Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs.”

The following non-public APIs are included in your application:

addTextFieldWithValue:label: textFieldAtIndex:

Rehman says September 26, 2011

The project is not complete and gives the following warnings

‘UIAlertView’ may not respond to ‘-addTextFieldWithValue:label:’

Password Screen Application in iPhone | iPhone / iPod / iPad Software developing says December 19, 2011

[…] iPhone Tutorial | iPhone iOS4 iPad SDK Development & Programming Blog This entry was posted in IOS Development and tagged Application, iPhone, Password, Screen by sniuff. Bookmark the permalink. […]

Rameez says July 10, 2012

Nice Post….

Add Your Reply