简体   繁体   中英

iOS: How do I change keyboard type?

iOS: I have a problem changing my keyboard type.

It is quite simple to do if the input is into a UITextfield, eg

[textField setKeyboardType:UIKeyboardTypeNumberPad];

but I am NOT using a UITextfield. (All the examples I've seen are for UITextFields.)

I click on an array of numbers and, getting the row, column indices, wait for input provided by the UIKeyInput protocol, ie using its canBecomeFirstResponder, hasText, and insertText methods.

It works fine, but I get the default keyboard.

The keyboardType property is in UITextInputTraits, but I don't know to get to it.

Assuming that you're using the keyboard for your own custom view rather than an existing view, implement the UITextInputTraits protocol in your view. Then your view will have a keyboardType property just like UITextField and others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM