I've read so many solution on how can i focus a searchbar to make keyboard appear when i open my search view, and all of that are like this
[searchBar becomeFirstResponder];
mine is
[self.searchDisplayController.searchBar becomeFirstResponder];
but I tried both.
Now, I tried this, and I also added a
[self.searchDisplayController setActive:YES];
because I'm using a SearchDisplayController, but so far the best result i can have is to have the cursor on the searchbar, the uitableview with an overlay on it, but still no keyboard.
If I run the simulator I can type on the searchbar with my computer's keyboard, but on an iPhone I can't do anything.
If you want to give a look to my code: http://nopaste.info/39fcda4771.html the focus should be executed in viewDidLoad method
Thanks again.
The sequence matter
If no luck then check if delegate of the search display controller is linked. Also worth checking the tint colour of the search bar.
I was showing searchbar on textFieldDidBeginEditing:(UITextField *)textField delegate method.
Keyboard was not showing. So for that first resign textField as firstResponder. i.e.
Then call method with delay
Where
}
It works
Use the UISearchBarDelegate and declare the searchBar in the header file like this ...
and declare your search bar in loadView
}
and then use becomeFirstResponder on your search bar in viewDidAppear
}
On the
simulator
, make sure that you click onToggle Software Keyboard
to use the keyboard of the simulator as you can see in the image.