Reputation: 309
I have a ViewController that is just a textfield, a next button, and a back button. I want the text field to always be editable while having the keyboard always present. I also want to customize the keyboard to be my own, but that will come once I figure this part out.
EDIT: The keyboard in my case will only actually be a keypad with 10 digits and a backspace key
What is the best way to go about this? I've been working around with having a UITextField that works with a custom keyboard view, and then make that the first responder when the view loads, but maybe there are better ways.
Thanks in advance!
Upvotes: 2
Views: 2728
Reputation: 2017
And in case you want to really have your own keyboard. create a view properly sized and beautified ;).. and put in the textFiled's inputView
property.
textField.inputView = your custom keyboard view
Cheers.
Upvotes: 0
Reputation: 318794
In the view controller's viewWillAppear:
method you can call becomeFirstResponder
on the text field. This will make the keyboard appear automatically when the view controller appears. As long as there is no other way to dismiss the keyboard, that is all you need.
Of course on the iPad there is a button on the keyboard to dismiss it. If you want to stop that button from working then implement the following delegate method:
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
return NO;
}
Upvotes: 0
Reputation: 77631
To make a UITextField always use the keyboard...
In the viewDidAppear
or viewWllAppear
function do this...
[self.textField becomeFirstResponder];
This will make the keyboard appear and the textField respond to the input.
To dismiss the keyboard you have to run...
[self.textField resignFirstResponder];
As long as you don't run this it will keep keyboard focus.
Upvotes: 1