1. UITextField initialization and setting UITextField * textField = [[UITextField alloc] initWithFrame: CGRectMake (10,200,300, 40)]; textField. borderStyle = UITextBorderStyleRoundedRect; textField. font = [UIFont systemFontOfSize: 15]; textField. placeholder = @ "enter text"; textField. autocorrectionType = UITextAutocorrectionTypeNo; textField. keyboardType = UIKeyboardTypeDefault; textField. returnKeyType = UIReturnKeyDone; textField. clearButtonMode = UITextFieldViewModeWhileEditing; textField. contentverticalignment = UIControlContentVerticalAlignmentCenter; textField. delegate = self; [self. view addSubview: textField]; [textField release]; 2. to implement the Delegate method, enable or disable the keyboard to display keyboard: [textField becomeFirstResponder];-(BOOL) textFieldShouldBeginEditing :( UITextField *) textField {[textField becomeFirstResponder ;} hide keyboard [textField resignFirstResponder];-(BOOL) textFieldShouldReturn :( UITextField *) textField {[textField resignFirstResponder]; return YES ;}