2

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!

4

3 に答える 3

1

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.

于 2013-02-11T23:10:07.633 に答える
0

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;
}
于 2013-02-11T23:12:52.197 に答える
0

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.

于 2013-02-12T05:59:59.420 に答える