xcode 4 - 自定义键盘 [英] xcode 4 - custom keyboard

查看:131
本文介绍了xcode 4 - 自定义键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击TextField时,有没有办法停止默认键盘并使用我自定义设计的键盘?

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

我已经设计了我的按钮,总是可以使用类似于一个计算器。它的数字从0到9,小数点和退格。

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

推荐答案

从iOS 3.2开始,你可以附加任何 UIView 到你的 UITextField 用作键盘:

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;

顺便说一句,如果你需要一个0-9的数字键盘,小数点和Backspace ,您可以使用UITextField的 UIKeyboardTypeDecimalPad 类型。但是这个只能从iOS 4.1开始提供,你必须知道某些语言环境使用逗号而不是点作为小数分隔符,并且此键盘类型显示关于设备当前语言环境的逗号或点它正在运行。

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.

这篇关于xcode 4 - 自定义键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆