In iPhone application can we add any such key to the keybord which when pressed will remove the keyboard from the view?
I have a table view in which there are almost 16 text boxes where in i am taking input from the user but once the we are done with the editing of the textboxes the keyboard should hide which is开发者_C百科 not happening.I saw in one application where we can have an costume keyboard and add an key/button to it on click of which the key board will get removed from the view?any one have any idea...
Setup textfield like the following code, particularly add event on UIControlEventEditingDidEndOnExit and set returnKeyType to UIReturnKeyDone
//username text
UITextField* usernameTF=[[[UITextField alloc] initWithFrame:CGRectMake(90,40,210,31)] autorelease];
usernameTF.placeholder=@"Username";
[usernameTF setFont:[UIFont systemFontOfSize:20.0]];
[usernameTF setBackgroundColor:[UIColor clearColor]];
usernameTF.clearsOnBeginEditing=TRUE;
usernameTF.enablesReturnKeyAutomatically==TRUE;
usernameTF.clearButtonMode=TRUE;
[usernameTF setTextColor:[UIColor grayColor]];
[usernameTF setBorderStyle:UITextBorderStyleRoundedRect];
usernameTF.contentHorizontalAlignment=TRUE;
usernameTF.returnKeyType=UIReturnKeyDone;
[usernameTF addTarget:self action:@selector(textOver:) forControlEvents:UIControlEventEditingDidEndOnExit];
and then on selector action implement this method-
-(IBAction)textOver:(id)sender{
[sender resignFirstResponder];
}
if you want to add done button to numeric keypad then check out the following link http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key it works for me. let me know if you have any problem.
精彩评论