如何检测“ABC”何时出现在 uikeyboard 上点击按钮,输入“UIKeyboardTypeNumbersAndPunctuation”
我想检测何时在 uikeyboard 类型“UIKeyboardTypeNumbersAndPunctuation”上点击“ABC”按钮,以及何时在字母键盘类型上点击“123”按钮。
我有“UITextview”控件
,请让我,谢谢
I want to detect when "ABC" button is tapped on uikeyboard type "UIKeyboardTypeNumbersAndPunctuation" as well as i want to detect when "123" button is tapped on alphabetic keyboard type.
I am having "UITextview" control
Pls let me and thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,您不想替换您想要检测的数字,是否按下了以下按钮?
如果是这样,据我所知,这不是正式可能的。 Apple 不提供“UIKeyboardTypeDidChange”通知,并且您无法在遵循准则的情况下编辑/更改键盘视图。如果您尝试的话,您的申请很可能会被拒绝。
(这并不是说如果您破坏键盘视图就不可能实现)。
As far as I can tell you don't want to replace numbers you want to detect is the following button is pressed?
If so, as far as I'm aware it's not officially possible. Apple doesn't provide a 'UIKeyboardTypeDidChange' notifications, and you can't edit / alter the Keyboard view while staying within guidelines. Likely your application would get reject if you tried.
(This isn't to say it wouldn't be possible if you hacked away at the Keyboard View).
- 此代码仅允许文本视图中的数字
如果您的目标是 iOS 4.1 及更高版本,则可以使用 UIKeyboardTypeDecimalPad。如果您需要支持旧版本,需要小数点,并且不需要其他任何内容,则必须创建自定义键盘。
如果您想过滤掉其他键而不删除它们,请指定某个对象作为文本字段的委托。该对象应包含以下代码:
对于字母表和其他代码,您可以将上面的代码与代码 ^[0-9a-zA-Z] 一起使用。我认为它对您有用。祝你度过愉快的一天
- This code allow only numbers in textview
If you are targeting iOS 4.1 and later, you can use UIKeyboardTypeDecimalPad. If you need to support older versions, require a decimal point, and don't want anything else, you will have to create a custom keyboard.
If you want to filter out the other keys without removing them, assign some object as the text field's delegate. That object should contain the following code:
for alphabet and others you use above code with this like code ^[0-9a-zA-Z].I think it is useful for you. have a grate day
使用textView的委托协议的(void)textViewDidChange:(UITextView *)textView。这应该可以解决你的问题。
use - (void)textViewDidChange:(UITextView *)textView of textView's delegate protocol. This should solve your problem.