I have three text fields in one page, when the textfield is empty, then the keyboard should show return keyboard, otherwise it should show search, and by clicking on that search button we need to go to another view controller. can any explain with sample code?
Set delegate of your UITextField and them implement delegate function
To show search and return key
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
if ([textField.text isEqualToString:@""])
{
textField.returnKeyType=UIReturnKeyDefault;
}
else{
textField.returnKeyType=UIReturnKeySearch;
}
}
Coding on keyboard return button
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
if (textField.returnKeyType==UIReturnKeyDefault)
{
//Your Return Key code
}
else if(textField.returnKeyType==UIReturnKeySearch)
{
//Your search key code
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With