Create A LoginScreen In iPhone

In this application we will see how to create a LoginScreen in iPhone. This is the very simple application. Let see how it will be worked using Interface Builder.

Step 1: Create a new application using View base template.Give the application name “LoginScreen”.

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: xpand classes and notice Interface Builder created the LoginScreenViewController class for you. Expand Resources and notice the template generated a separate nib, LoginScreenViewController.xib, for the “LoginScreen”.

Step 4: In this LoginScreenViewController.h file we have added two UITextField for username and password, one UIButton for login, UIActivityIndicatorView for indicator and added one IBAction method. So make the following changes in the file.

 

 

 

Step 5: Double click the LoginScreenViewController.xib file and open it to the Interface Builder. First drag two label from the library and place it to the view window, change the label name into Username and Password.Again drag two TextField from the library and place it to the view window. Next drag Button and ActivityIndicator from the library and place it to the view window. Now connect File’s Owner icon to View icon and select the view. Select the File’s Owner icon and bring up Connection Inspector next drag indicator to the Gray Activity Indictor, another time drag from the userName and password to the two TextField. Select RoundRect button and bring up Connection Inspector next drag from the TouchDown to the File’s Owner icon and select loginButton: action. Now save it , close it and go back to the Xcode.

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

 

 

 

Step 7: Now compile and run the application in the Simulator.

You can Downloaded SourceCode from here LoginScreen

Leave a Comment:

7 comments
Fabio says August 30, 2010

Nice but I would like to see a real world example!

Reply
RajeeBala says September 29, 2010

Hi,
The Given code Has A Small Loop Hole.In The Password Text Field ,when We Enter Any Text it is displayed as it was typed instead it has to take a encrypted format like "*****". in order to achieve this, in the .m file under view did load method place the following code and then run the project

password.secureTextEntry = @"*";

Thanks&Regards

RajeeBala

Reply
nanonyme says January 27, 2011

How about writing a guide on integrating a login screen into a control flow managed by navigation controller where authentication is required in some steps? That’s the part about login screens that actually needs thinking through.

Reply
Soumya says March 28, 2011

i was actually looking for a login screen if username and password are empty show error msg screen if clicked on error msg screen it should come to login screen if username and password are not nil then go to another screen how please help me

Reply
monta says October 7, 2011

when i want to move to my tableview after a login screen how can i do please

Reply
hajer says April 18, 2012

i tried the code i have 7 errors due to alloc 🙁
any help ?

Reply
login xcode app says August 14, 2014

[…] Create a LoginScreen in iPhone | iOS Programming Tutorials … […]

Reply
Add Your Reply