Prevent default keyboard from showing when UITextField is pressed

自闭症网瘾萝莉.ら 提交于 2020-01-10 05:04:25

问题


Is there a way to make a custom keyboard to pop up when a user presses on a UITextField. I have a view with a custom keypad on it and I want that to come up when the user presses on the UITextField instead of the default apple keyboard.


回答1:


Since iOS 3.2 there's a property for exactly that, called inputView.

just go like this: [myTextField setInputView:myInputView] - where myInputView is obviously your custom input view. Then the system will pop up your view instead of the predefined keyboards.




回答2:


You may set delegate in your UITextField and return NO in textFieldShouldBeginEditing:.




回答3:


not sure I understand the question? the keyboard type can be assigned to the UITextField so If you want a different one then specify it when initializing the object

UITextField * textFld = [[UITextField alloc] init];
textFld.keyboardType = UIKeyboardTypeNumbersAndPunctuation;

http://developer.apple.com/iphone/library/documentation/uikit/reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html#//apple_ref/doc/c_ref/UIKeyboardType



来源:https://stackoverflow.com/questions/3175849/prevent-default-keyboard-from-showing-when-uitextfield-is-pressed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!