[英]How to associate iOS keyboard “go” button with UIButton?
我的SearchViewController
有一個搜索欄,當前,當他們在其中鍵入內容時,沒有“ 轉到”按鈕,它僅顯示return 。 我想要一個Go按鈕顯示在鍵盤上,並且我希望它連接到- (IBAction)nextButton:(id)sender
,我已將其連接到搜索欄下方的現有下一個 UIButton
。
我如何才能啟用它並以這種方式連接它? 為了澄清起見,搜索欄和下一個按鈕是在情節提要中創建的,而不是以編程方式創建的。
[textField setReturnKeyType:UIReturnKeyGo];
要么
- (void)setReturnKey {
//use condition here(not empty field)
self.searchField.returnKeyType = UIReturnKeyGo;
}
戈布斯說的另一件事是,您可以在這里找到...
- (BOOL) textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];//Dismiss the keyboard.
//Add action you want to call here.
return YES;
}
上面的代碼的來源: ios鍵盤的“執行”按鈕的操作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.