Reputation: 859
I have a search bar in my SearchViewController
, and currently, when they type into it, there's no Go button, it shows only return. I want a Go button to show in the keyboard, and I want it to be connected to the - (IBAction)nextButton:(id)sender
that I have connected to the existing next UIButton
under the search bar.
How do I go about enabling this and connecting it in this way? To clarify, the search bar and next button were created in storyboard, not programmatically.
Upvotes: 2
Views: 1099
Reputation: 505
[textField setReturnKeyType:UIReturnKeyGo];
or
- (void)setReturnKey {
//use condition here(not empty field)
self.searchField.returnKeyType = UIReturnKeyGo;
}
the other thing as Ghobs said you can find here...
- (BOOL) textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];//Dismiss the keyboard.
//Add action you want to call here.
return YES;
}
source for above code:Action of the "Go" button of the ios keyboard
Upvotes: 3