xcode 4 - custom keyboard

孤人 提交于 2019-12-04 02:17:55

问题


Is there a way to stop the default keyboard and have my custom designed keyboard when user clicks on TextField ?

I already designed my buttons to be always available similar to a calculator. It has numbers from 0 to 9 , decimal dot and backspace.


回答1:


Starting with iOS 3.2, you can attach any UIView to your UITextField to be used as a keyboard:

myTextField.inputView = myFakeKeyboard;

You can also attach a toolbar above the keyboard (system or custom one) :

myTextField.inputAccessoryView = myToolbar;

By the way, if you need a numeric pad with 0-9, the decimal dot, and Backspace, you can use the UIKeyboardTypeDecimalPad type for your UITextField. But this one is only available starting from iOS 4.1, and you have to be aware that some locales use a comma instead of a dot as a decimal separator, and this keyboard type shows a comma or a dot regarding of the current locale of the device it's running on.




回答2:


You need to use this in your viewController and its enough :)

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
     return NO; //hide keyboard
}


来源:https://stackoverflow.com/questions/9451912/xcode-4-custom-keyboard

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