KeyBoard Example In iPhone

This is the simple KeyBoard example. In this example we will see how to keyBoard implement the application and hide from the application using button pressed. So let see how it will worked. My last post you can find out from here  MoveImage

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

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: Open the KeyBoard_ExampleViewController.h file, make the following changes:

 

#import <uikit/UIKit.h>

@interface KeyBoard_ExampleViewController : UIViewController {

IBOutlet UITextField *textField;

}

@end

 

 

Step 4: Double click the KeyBoard_ExampleViewController.xib file and open it to the Interface Builder. First drag the label and place it to the view window, change the label name into “Name” and drag the TextField from the library and place it to the view window. Select the TextField and bring up Attributes Inspector and the placeholder into”Enter your name” and select the TextFiled once again and bring up Connection Inspector and connect delegate to the File’s Owner icon. Now, save the .xib file and go back to the Xcode.

Step 5: In the KeyBoard_ExampleViewController.m file make the following changes:

 

#import "KeyBoard_ExampleViewController.h"
@implementation KeyBoard_ExampleViewController

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}

- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];

}
#pragma mark - View lifecycle
- (void)viewDidUnload
{
[super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

 

 

Step 6: Now compile and the run the application on the Simulator.

You can Download SourceCode from here   KeyBoard_Example