New to iPad development. I would like to use a custom numeric keyboard (using a pod) on iPad, but the native one on iPhones. Is it possible to make an extension on UITextField, UITextView to set/get inputView/keyboardType? Or is there an other solution?
myTextField.keyboardType = .decimalPad
extension UITextField {
....
case .decimalPad:
if UIDevice.current.userInterfaceIdiom == .pad {
...
}
You can set a custom input view using the
inputViewproperty ofUITextField. If it is not set, the default keyboard (as configured on the text field) will appear when the text field becomes first responder. So only set if to your custom numeric keyboard view when running on iPad and leave it as-is on iPhone.EDIT
Initially I pointed out
inputAccessoryViewinstead ofinputView, hence the confusion in the comments.