[英]In iPhone application can we add any such key to the keybord which when pressed will remove the keyboard from the view?
我有一個表格視圖,其中有將近16個文本框,這些文本框用於接收用戶輸入,但是一旦完成對文本框的編輯后,鍵盤應隱藏沒有發生的情況。在一個應用程序中,我們看到了可以有一個服裝鍵盤並在其上添加一個鍵/按鈕,單擊該鍵/按鈕將從視圖中刪除鍵盤?任何人有任何想法...
像以下代碼一樣設置文本字段,特別是在UIControlEventEditingDidEndOnExit上添加事件並將returnKeyType設置為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];
然后在選擇器操作上實現此方法-
-(IBAction)textOver:(id)sender{
[sender resignFirstResponder];
}
如果您想在數字小鍵盤上添加完成按鈕,請查看以下鏈接http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key,它對我有用。 如果您有任何問題,請告訴我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.