How do I create a keyboard search action?
I have three textboxes on one page, when the textbox is empty then the keyboard should display a reverse keyboard, otherwise it should show a search and by clicking on that search button we need to navigate to another view controller. can someone please explain with an example code?
+3
source to share
1 answer
Install delegate
yours UITextField
and implement the functiondelegate
To display the keys search
andreturn
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
if ([textField.text isEqualToString:@""])
{
textField.returnKeyType=UIReturnKeyDefault;
}
else{
textField.returnKeyType=UIReturnKeySearch;
}
}
Encoding on the keyboard return button
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
if (textField.returnKeyType==UIReturnKeyDefault)
{
//Your Return Key code
}
else if(textField.returnKeyType==UIReturnKeySearch)
{
//Your search key code
}
}
+5
source to share