Text fields are for single line text.  For multi line text use Text View

Delegates

textFieldShouldReturn

Keyboard return key pressed

Example Of Use

Declaring in #ViewController.h file

	IBOutlet UITextField *MyTextFieldName;
Releasing in #ViewController.m file

//********** VIEW DID UNLOAD **********
- (void)viewDidUnload
{
	[super viewDidUnload];

	[MyTextFieldName release];
	MyTextFieldName = nil;
}

//********** DEALLOC **********
- (void)dealloc
{
	[MyTextFieldName release];

	[super dealloc];
}
Connecting in Interface Builder

Add the text filed to the view
Right click Files Owner
Drag the outlet to your text field

Set Text


	[MyTextFieldName setText:@"ABC"];
	[MyTextFieldName setText:[NSString stringWithFormat:@"%d", self.MyIntValue]];

Read Text


    NSString MyString = MyTextField.text;

Storing Values Entered In A Text Field


	SomeIntVariable = [[SomeTextField text] intValue];

Dismissing The Keyboard & Responding To Input

Open the XIB.
For each of the text fields, right click and drag the 'delegate' circle to 'Files Owner'

Then in #ViewController.m:

//********** TEXT FIELD SHOULD RETURN **********
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
	[textField resignFirstResponder];
	return YES;
}
If you have any methods in #ViewController.m that want to ensure the keyboard is removed:

//********** VIEW WILL DISAPPEAR **********
- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];

	[[self view] endEditing:YES];		//Ensure keyboard is removed
}

Text Field Entered Method


-(void)textFieldDidBeginEditing:(UITextField *)textField //Keyboard becomes visible
{
	if (textField == TextPassword)
	{
		if ([[TextPassword text] isEqual:@"********"])
		{
			[TextPassword setText:@""];
		}
	}

}

 

Text Field Exited Method


-(void)textFieldDidEndEditing:(UITextField *)textField { //keyboard will hide
{
	if (textField == TextPassword)
	{
	}

}