如何检测iOS默认键盘类型何时从文本切换到数字 [英] how to detect when the iOS default keyboard type switches from text to numbers

查看:400
本文介绍了如何检测iOS默认键盘类型何时从文本切换到数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多帖子,当键盘类型从数字键盘变为默认值时通知用户。这个问题是关于用户实际点击 [123] [ABC] 按钮

There are many posts about notifying the user when the keyboard type changes from things like the numberpad to default. This question is about knowing about when the user actually clicks on the [123] or the [ABC] button on the default keypad.. basically I want to know when this screen

更改此屏幕

尝试:

-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    NSLog(@"::::::: this is text field type %d", searchBar.keyboardType);

自然总是给我回来 0 默认键类型..因为它假设两者是相同的键盘类型。

naturally always give me back 0 which is the default key type.. since it's assuming both are of the same keyboard type.

推荐答案

没有API检测键盘更改:UITextField类引用

There is not API to detect Keyboard changed: UITextField class reference

keyboardType的定义是UITextInputTraits协议的一部分。设置keyboardType,例如ASCII,基本上是显示键盘自身的字母部分的标准键盘。如果将keyboardType设置为UIKeyboardTypeNumbersAndPunctuation,您将获得与ASCII相同的键盘,希望键盘首先显示为键盘的数字部分。

The definition of the keyboardType is part of the UITextInputTraits protocol. Setting a keyboardType, e.g. ASCII, is basically the standard keyboard showing the letter part of the keyboard self. If you set keyboardType to UIKeyboardTypeNumbersAndPunctuation, you get the same keyboard as the ASCII expect that the keyboard is shown with the number part of the keyboard first.

总之,ASCII和数字和标点键盘是相同的三屏键盘,以两种不同的方式呈现。

In Summary, ASCII and the Numbers and Punctuation keyboard are the same, three-screen keyboard that are presented in two different ways.

这篇关于如何检测iOS默认键盘类型何时从文本切换到数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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